CYTHEIA AIOpen the editor

Battery Powered LED

A self-contained circuit: flip the switch to power an LED from a 9V battery.

Open this circuit and run it

Opens in your browser with the parts, wiring and code already in place. Press Run to watch it work, then change anything you like.

How it works

This is a pure hardware circuit with no Arduino: the positive terminal of a 9 volt battery goes to a switch, then through a resistor and the LED, and back to the battery’s negative terminal. Closing the switch completes the loop so current flows and the LED lights; opening it breaks the loop. The resistor matters even more here than in the Arduino examples: with 9 volts across an LED and nothing to limit the current, the LED would burn out.

The sketch is empty on purpose, because the Arduino is not part of this circuit; the simulator just expects setup() and loop() to exist. Click the switch in the editor to open and close it. It shows the idea behind every circuit on this site: current needs a complete loop from the power source, through the parts, and back.

Parts

Wiring

Arduino code

// Battery Powered LED
// A pure hardware circuit: the switch closes the loop
// between the 9V battery, resistor and LED.
void setup() {
}

void loop() {
  delay(1000);
}

Try changing it

Open this circuit and run it

Next challenge

More projects in LED & Lighting