All tutorials

1 · First steps

Two alternating LEDs

Beginner10 min

Goal

Alternate two LEDs (pins 12 and 13) like a level crossing.

Why it matters

You learn to drive several independent outputs inside the same loop.

Steps

  1. 01Add a second LED + resistor on pin 12.
  2. 02Declare both pins as OUTPUT.
  3. 03In loop(), set one HIGH while the other is LOW, then swap.

This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.

Next tutorials