Lesson goal: Read a digital input from the Arduino (a 1 or 0 only)

Home

In a previous lesson, you saw how to read a digital input, which was always a 0 or a 1. It might have seemed kind of silly to have such limit data. But it is not. Here's an example of digital information: a switch. A switch can be either pressed or unpressed. These are the two possible states of a switch. You can think of pressed as a 1 and unpressed as a 0--see TWO states. A switch is kind of a digital device.

Wire up the circuit shown below, then run the following code. Press the button a few times. What do you see as the output?

Now you try. Seeing how a push-button switch returns digital information.

Type your code here:


See your results here: