Switch Interfacing & Debouncing |
Over here we consider ONE Switch & TWO LED connected to a microcontroller. Please check the SWITCH INTERFACING and the LED INTERFACING article to see how to connect Switches & LED’s to a microcontroller. |
Here is a program that will TURN ON A LED1 if a switch is debounced properly & will TOGGLE LED2 if there is some error in switch debouncing. LED1 will be ON until the switch is pressed & will turn OFF as soon as it’s released. We have taken the debounce period as 20ms. So once a LOW signal has been received from the switch the controller will again check the switch status after 20ms & if at that time the switch is high LED2 will be toggled and if the switch is LOW LED1 will be turned ON.
|