Debounce made visible
When using mechanical switches in electronic circuits we encounter the difficulty of what is called “bouncing”. A switch often contains a spring-like contact that, when pushed, bounces up and down sometimes and in doing so, creates multiple pulses. We only intend to give ONE pulse.
In the picture on the right you can see a dirty keypress, represented by the yellow line. Time goes from left to right and we see that the key pulls the signal low, and about 5 milliseconds later bounces so that the signal is high for a brief moment and then comes back to low again.
There are lots of solutions for this problem. One of these is using the 555 timer chip. You can see the circuit on a breadboard in this picture. it basically holds the signal high by using a RC delay (Resistor / Capacitor). In this case I used a 1 Mega ohm Resistor and a 300 nano Farad Capacitor. As we will see, this leads to a 300 milli second delay.
Cleaned up pulse
Here you can see what the circuit does to the dirty keypress. You see the clean pulse, represented by the blue line.
You can see by looking at the time scale below (50 ms) that this pulse is 350 ms long, which is about the length of the keypress (± 80ms, see above) plus the length of the RC delay.
Nice, isn’t it?
The pulses zoomed in: