Wire it on a real board

Using only the on-⁠screen board? You can skip this step.

You need a push button, a 10K ohm resistor, a breadboard and three wires4.

Wire the button

  1. Run a wire from pin 2 to one leg of the button4.
  2. From that same leg, connect the 10K resistor to GND4.
  3. Connect the other leg of the button to 5V4.

Why the resistor?

With the button up, the resistor joins pin 2 to GND, so it reads LOW4.

With the button down, the button joins pin 2 to 5 volts, so it reads HIGH4.

Without the resistor, pin 2 is floating. It reads HIGH or LOW at random5.

Upload it and press

  1. Lesson 1, step 3 shows how to upload. Upload the sketch from step 2 the same way.
  2. Hold the button down. The light on pin 13 comes on, and it goes out when you let go3.
Before you run it on a real board, check each connection

Not working? Start with the Stuck? checklist.

Sources for this page

  1. Arduino example: Button.ino: public domain
  2. Arduino tutorial: How to Wire and Program a Button: pull-⁠down resistor; a floating pin
  3. Arduino reference: digitalRead