Difference: Switches (6 vs. 7)

Revision 72021-06-24 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Exercises"

Exercise 3: Switches

Introduction

Line: 27 to 27
 Do the same thing as in exercise 1 but use external interrupts and a callback routine to do the job.

Exercise 3:

Changed:
<
<
Combine this exercise with the exercise on LEDs: Switch the builtin LED on when the button is pressed and off when it is released
>
>
Combine this exercise with the exercise on LEDs: Switch the built-in LED on when the button is pressed and off when it is released
 

Exercise 4:

Changed:
<
<
Write a program scanning the PIR sensor, indicating if a person is close. The PIR sensor, just like the push button, uses a single GPIO line as input. The boards allows to choose which GPIO to use and I selected D4 = GPIO 16
>
>
Modify exercise 3 such that a single push-and-release will switch the LED on, and a second push-and-release will switch it off again. This type of switches you find e.g. on table lamps. You may find that your program sometimes does not work as expected, which may be due to switch bouncing. In this case please modify your program adding a debounce algorithm to it. You can write a software debouncer, waiting a short while after a switch state change (typically ~ 10 ms) making sure that the switch level has stabilized.
 

Exercise 5:

Added:
>
>
The ESP32 has an interface to read capacitive touch sensors (see https://docs.micropython.org/en/latest/esp32/quickref.html?highlight=touchpad). Write a program to read out the touch sensor and to find out if a wire is touched or not. You may use this again to switch on and off LEDs.

Exercise 6:

Write a program scanning the PIR sensor, indicating if a person is close. The PIR sensor, just like the push button, uses a single GPIO line as input. The boards allow choosing which GPIO to use, and I selected D4 = GPIO 16

Exercise 7:

 The sensor kit in the lab contains a big number of sensors acting like switches:
  • rolling ball switch
  • mercury switch
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback