What you’ll make

In this lesson your board reads a push button. While you hold the button down, the light on pin 13 comes on3.

A push button joins two wires while you press it4.

The button is wired to pin 2. Your code reads pin 2 to find out if the button is down.

See it first

Press Run. Then hold the on-⁠screen button down, and let go. With a keyboard, move to it with Tab and hold Space.

What you need

  • For the on-⁠screen board: nothing. It runs in this page.
  • For a real board: an Arduino UNO R3 and a USB cable.
  • Also a push button, a 10K ohm resistor, a breadboard and three jumper wires4.

Next, you’ll read the code one line at a time.

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