Skip to content

Blink an LED

Make the board's built-in LED turn on for one second, then off for one second, forever.

Starter code

Open blink_starter in the Arduino IDE and fill in the TODOs.

blink_starter.ino
// Blink: turn the built-in LED on for one second, then off for one second, forever.

void setup() {
  // TODO: set LED_BUILTIN as an output
}

void loop() {
  // TODO: turn the LED on, wait 1 second, turn it off, wait 1 second
}
Solution
blink_solution.ino
// Blink: turn the built-in LED on for one second, then off for one second, forever.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Try it

  • Change the delays to make the LED blink faster.
  • TODO: wire an external LED and resistor to pin 13.