By the end of this lesson students need to know how to set a digital pin for sensing a voltage rather than turning a voltage on or off. They also need to understand the difference between voltage and current. A digital pin set to INPUT mode has a very high resistance, meaning very little current will pass through it.

Students also need to understand the concept of the pull-up resistor. By connecting one end of a resistor to a digital pin and the other end to +5 volts we are "pulling" the voltage on that pin "up" to five volts.

When pushed, the push button connects that pin directly to ground (GND), resulting in the voltage being zero. If the pull-up resistor has a high value, such as the 10,000 ohms used here, then very little current actually flows to ground. What is important is:

  • When the button is pushed the digital pin is connected to ground. The value returned by digitalRead() will be LOW.
  • Whne the button is released the pull-up resistor brings the voltage on the digital pin to +5. The value returned by digitalRead() will be HIGH.

Students who read Arduino documentation closely may discover the Atmel ATmega 328 integrated circuit the ability to "pull up" pins internally under program control. This is true, although with some limitations. Use of this capability is not taught here as the programming statements do not reinforce learning the concept of switching measurable voltages on an Arduino digital pin.


By far the most common student mistakes are with wiring the pushbutton. In particular:

  • that the pushbutton connects diagonally across the pins. The jumper to the Arduino and the jumper to ground must be at opposing corners of the push button, not directly across.
  • that the pushbutton pins must be inserted far enough into the breadboard to make electrical connection. The push buttons should sit flat and snug on the breadboard.
  • that the value of the resistor must be high. The lesson calls for 10,000 ohm resistors (red-brown-orange). Up to now all resistors have been 220 ohm (red-red-brown). While one of these will work the use will needlessly waste power.

Often a student will accidently connect +5 volts directly to ground, either directly or when the push button is pushed. When this happens, the power light on the Arduino Uno goes off. Students will usually report something wrong with their Arduino. They rarely recognize the problem is power shorted to ground. So, be suspicious of any report of, "my Arduino isn't recognized by my computer anymore." Such failures do happen, but aren't common. Look first for some connection of +5 volts to ground.

Students will sometimes attempt to use pin 13 for input. This does not work reliably because the Arduino Uno has an internal LED connected to this pin.

Finally, some students will insist the wiring of the pushbutton must somehow be connected to the wiring of the LED. This is an opportunity to point out the wiring of the two is entirely independent. What is happening is the Arduino is detecting the state of the push button and from this information is deciding whether to turn the LED on or off. This concept is key to understanding what a computer does when controlling circuits.


Here is the pushbutton wiring:


What shold happen when the button is pushed:


Exercise where LEDs alternate when button pushed


Rapidly alternating LEDs when the button is pushed