This lesson will show you how to read a digital input from one of the digital inputs (2..13) on the Arduino.
Move the mouse over a dotted box for more information.
Now you try. Read digital inputs from the outside world. Note the values returns are either a 1 or a 0. This
is the raw nature of digital information.
Type your code here:
See your results here:
Although pins 0 and 1 are available, you shouldn't use them, as this will interfere with the Arduino's
communication with your computer.
Note we have to use pinmode(2,INPUT) to set pin 2 to be an input, which here means to take in data from
the outside world.
This experiment only requires the Arduino and a single wire. Insert one end of the wire into the pin labeled "2," as shown
here. Insert the free end of the wire into the 5V pin and run the code above. What do you see displayed on the screen?
Next, remove the end from the 5V pin and insert it into the 0V pin and run the code again. Do you see how a digital value
is either a 1 or a 0? What input voltage gives a 1? A 0?