02 2015

Controlling the LED with a PushbuttonKate Auerbach

Let's start with a simple example of the LED controlled by a pushbutton. For this project we would need:

The full description can be found in Getting Started with Arduino by Massimo Banzi.

Getting Started with Arduino
Banzi, Massimo. Getting Started with Arduino. Maker Media, Inc, 2011.

Connecting the LED and the pushbutton to pins 13 and 7, we set up the Arduino input and output. Every time we push the button, we need to check the state of the input pin and store its value. If this value is HIGH, the LED turns on.

A simple circuit below gives you the idea of how to connect all your parts.

Hooking Up a Pushbutton
Building the Circuit

Then, upload the code into your Arduino IDE. If everything is correct, the LED will light up when you press the button. See how I did it below.

LED OFF LED ON
Let the light shine in!
Go Back