Understanding the debounce concept
Now here is a small section that is quite cool and light compared to analog inputs, which we will dive into in the next chapter.
We are going to talk about something that happens when someone pushes a button.
What? Who is bouncing?
Now, we have to take our microscopic biocybernetic eyes to zoom into the switch's structure.
A switch is made with pieces of metal and plastic. When you push the cap, a piece of metal moves and comes into contact with another piece of metal, closing the circuit. Microscopically and during a very small time interval, things aren't that clean. Indeed, the moving piece of metal bounces against the other part. With an oscilloscope measuring the electrical potential at the digital pin of the Arduino, we can see some noise in the voltage curve around 1 ms after the push.
These oscillations could generate incorrect inputs in some programs. Imagine, that you want to count the states transitions in order, for instance, to run something when...