Button-controlled LED
Press a pushbutton to light an LED. Discover why an input pull-up makes a pressed button read LOW.

Wire it up
Disconnect power before changing connections. Follow terminal names rather than wire colors.
| From | To | Why it matters |
|---|---|---|
| Uno · 13 | Resistor (r-led1) · 1 | Match this terminal to the sketch |
| Resistor (r-led1) · 2 | LED (led1) · A | Match this terminal to the sketch |
| LED (led1) · C | Uno · GND.1 | Ground reference |
| Pushbutton (button1) · 1.l | Uno · 2 | Match this terminal to the sketch |
| Pushbutton (button1) · 2.l | Uno · GND.2 | Ground reference |
The complete sketch
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, digitalRead(2) == LOW);
}
The launch buttons use this same code and a matching saved circuit.
Build it step by step
Open a complete project
Launch in Simulator creates a separate Uno sketch and its matching wired circuit. Existing sketches are preserved. Press Run to compile and execute.
Explore the live circuit
Press and release the simulated pushbutton. The LED should follow it immediately.
Try it on hardware
Disconnect power while wiring. Match terminal names in the table, select the exact board, Verify, then connect and upload. Check component ratings and power requirements first.
Understand the sketch
Active-low input
INPUT_PULLUP holds D2 high when the button is open. Pressing it connects D2 to ground; the comparison turns that LOW reading into an LED-on command.
If something is different
LED always on
Connect opposite button contacts, 1.l and 2.l. The two terminals on the same contact are already joined.
Expected output and tested scope
With INPUT_PULLUP, pressing the button pulls the input LOW and turns on the LED; releasing it turns the LED off.
Version 1 · Last source- and build-matched test: 2026-10-25. Actual shipped AVR-GCC WASM compilation and Uno AVR engine execution; no physical hardware test.
Supported tutorial target: Arduino Uno R3 / ATmega328P. Compile: PASS · Modeled execution: PASS. Other boards require a separate review of pins, voltage, libraries and the exact build profile.