This project has been excerpted and modified from Make: Getting Started with Arduino — 3rd Edition.

What You’ll Be Making

After you learn how to make an LED blink with your Arduino, you’re ready to tackle this project.

In this project you’ll learn how to turn your light on and off via a switch. You probably wouldn’t stay sane if your lamp were to continuously blink so it’s a good idea to learn how to control it.

When you learned how to make an LED blink, the LED blinking was your output. What’s missing was an input to control your output. We’ll use one of the most common and simple inputs: a pushbutton switch.

If you were to take apart a pushbutton, you would see that it is a very simple device: two bits of metal kept apart by a spring, and a plastic cap that when pressed brings the two bits of metal into contact. When the bits of metal are apart, there is no circulation of current in the pushbutton (a bit like when a water valve is closed); when you press it, you make a connection.

All switches are basically just this: two (or more) pieces of metal that can be brought into contact with each other, allowing electricity to flow from one to the other, or separated, preventing the flow of electricity.

How This Project Relates to the Real World

From vending machines to car stereos, many of the objects we interact with have pushbutton switches. Understanding how a button works with a microcontroller is fundamental to understanding how gadgets work, and ultimately, to making gadgets of your own with Arduino.