CYTHEIA AIOpen the editor

LED Blinker

Classic Arduino blink: LED on pin 13 with resistor to GND.

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

The Arduino’s pin 13 is wired through a resistor to the LED’s anode, and the LED’s cathode goes to ground. When the sketch sets pin 13 high it puts 5 volts across that path and current flows, lighting the LED; when it sets the pin low, the current stops. The resistor limits the current so the LED is not damaged. On its own an LED would draw far more than it can take.

setup() makes pin 13 an output and starts the serial connection. loop() then repeats forever: switch the pin on, print “LED ON”, wait 1000 milliseconds (one second), switch it off, print “LED OFF”, wait another second. Open the Serial tab while it runs to watch the messages arrive in step with the light.

Parts

Wiring

Arduino code

// LED Blinker
void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(13, HIGH);
  Serial.println("LED ON");
  delay(1000);
  digitalWrite(13, LOW);
  Serial.println("LED OFF");
  delay(1000);
}

Try changing it

Open this circuit and run it

Next challenge

More projects in LED & Lighting