Lights
Push-button light
Hold a button and an LED lights; let go and it goes out. The first step to a doorbell or a game buzzer.
- Easy
- about 20 min
- Arduino Uno
- No soldering
- 7 parts
- 5 wires
- 17 lines of code
Opens this circuit, already wired, with the sketch loaded. Free, nothing to install.
Idea
A button looks simple, but a pin with nothing connected reads noise. This build uses the Uno's built-in pull-up so the pin always has a clear answer.
What you learn
Reading a button with digitalRead(), and why INPUT_PULLUP makes a pressed button read LOW.
How it works
input
Push button
decides
Arduino Uno
output
LED
Powered with 5 V from the Uno's USB cable. No battery and no soldering.
This circuit and sketch are run in the ManuStem simulator before the pack is published. Real parts vary between makers: follow the labels printed on your own module, not its position in the picture.
Parts
0 of 7 ready
No prices here: they change by shop and by week. Buy each part by its name and the note beside it.
You also need
A computer with Arduino IDE 2 installed (free)
3D wiring
One jumper per step. Unplug the USB cable while you wire.
Step 0 of 5
Lay out the parts
Push the small parts into the breadboard as shown. Nothing is connected yet.
All connections
button-light.ino
// Push-button light
// ManuStem Build Pack: https://stem.manusignal.com/packs/button-light
const int BUTTON_PIN = 2;
const int LED_PIN = 9;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
digitalWrite(LED_PIN, HIGH);
} else {
digitalWrite(LED_PIN, LOW);
}
}
Libraries
None. It uses only what the Arduino IDE has built in.
Uploading
- Open the sketch in Arduino IDE.
- Plug the Uno in with the USB cable.
- Tools > Board > Arduino Uno, then Tools > Port and choose the board's port.
- Press Upload (the arrow). Wait for “Done uploading”.