Hardware Reference
In-Depth Information
• Learn how inputs and outputs can work together to make something
interactive
Switches: Digital Input
When you used digitalWrite() in Chapter 3 , there were two possible states
of a digital output pin: high or low. When it comes to digital input, the same
is true. When you read the state of a digital input, it will either be connected
to 5 volts, which indicates a high state, or to ground, which indicates a low
state. By connecting a simple pushbutton switch, you can change the state
of a digital input pin simply by pressing the button.
A pushbutton switch like the one pictured in Figure 4-1 is great for experi-
menting with digital input. It snaps right into the breadboard, and it's a com-
ponent that you'll frequently see in electronics starter kits. The two terminals
on the top of the switch are connected to each other, as are the pair on the
bottom. When you push down on the switch, both pairs of terminals are con-
nected together.
Because the terminals on opposite sides of the breadboard
are connected to each other, it means that the pushbutton is
making a connection across the gap in the breadboard just as
if you had put a jumper wire across the gap. So, in Figure 4-1 ,
this means that both sides of row 11 are connected, as are both
sides of row 13. But unless you are pressing the button down,
there is no connection between rows 11 and 13.
 
Search WWH ::




Custom Search