Connecting a button as a digital input
The simplest circuit that we can prepare to be used as a digital input is that consisting of a switch connected to a digital input of the Arduino board.
A typical momentary push button usually has two states, open or closed, and acts like a switch that, when not pressed, keeps the circuit open, preventing the connection between the two parts of the circuit it connects, and when pressed, makes these two parts connected.
Keeping in mind that an Arduino digital input can sense values of 0V and 5V, we have to prepare our circuitry in such a way that it provides a 0V signal to the Arduino digital input when we want to consider it LOW
and a 5V signal when we want to consider it HIGH
.
To be precise, the Arduino microcontroller can sense anything between 3V and 5V as a HIGH
value and something between 1.5V and 0V as a LOW
value, the range between 1.5V and 3V undetermined and, thus, not valid.
For the purposes of our first digital input example, we will use a very...