Site icon 14core.com

Working on Debounce / Interrupts on Switch with MCU

Switch are standard input to any electronic projects. Tactile switch works well in a PCB also can be used on a solderless breadboard. Switch are normally open or disconnected and when the push button is pressed are momentarily closed. Tactile switch are everywhere and they are especially popular in DIY electronics and microcontroller boards because they are well suited to act as a boot option or reset switch. Particularly, momentary switches are switches that don’t save their state you depress the switch. Below are the illustration that covers the purpose of the switch together with the microcontroller.

Interrupts are very useful feature in the microprocessor. Interrupts allows you to run a program while still being able to react to asynchronous input externally. Example below will demonstrate the uses of interrupt together with denouncing.

Tactile switch / Push Button generates open/close transition when pressed, due to a mechanical issue: these transitions may read a multiple press in a very short time. Without debouncing, pressing the push button once may generate an unpredictable results or noise. As you can see the code below its uses milis() function to keep track the time passed since the push button was pressed.

Required Components

Wiring Diagram Push Button Manual 

Wiring Diagram using the Push Button Module

Source Code / Sketch Code
[crayon-673f572e242da006319198/]
Source Code  / Sketch Code for Debounce & Interrupt

The code below will demonstration how to use debounce on the Arduino micro-controller using push button. When button press it will stay HIGH State if press again it will stay at LOW State.
[crayon-673f572e242e4167272930/]
 

Working on Debounce / Interrupts on Switch with MCU
Exit mobile version