Control it with a BUTTON

// WHAT YOU WILL LEARN

INPUT_PULLUP keeps the pin HIGH until the button pulls it to GND (LOW); one if/else switches the LED.

// LESSON NOTES

Part 6: control your LED with a BUTTON 🔘

Press → ON. Let go → OFF.

The trick: INPUT_PULLUP — a resistor built into the chip keeps pin 2 at 5 V (HIGH). Press the button and pin 2 connects to GND → LOW.

Then one if/else does the rest. 👀

Related lessons