02 / 20
Flash two LEDs
Build a crossing signal with two independently wired lights.
Run this experiment →Why it’s here
Change the two phase durations and compare the left and right LEDs.
How it works
Build a crossing signal with two independently wired lights. No. GPIO 2 and GPIO 4 are complementary; the full cycle includes both phases. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.
Try it
- Open this experiment
- Change the two phase durations and compare the left and right LEDs.
Connections
- GPIO 2 / 4 — Separate series resistor → left / right LED
- GND — Both LED cathodes
Example sketch
void setup() {
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
digitalWrite(2, HIGH); digitalWrite(4, LOW);
delay(500);
digitalWrite(2, LOW); digitalWrite(4, HIGH);
delay(500);
}Check your understanding
Are both lamps on at the same time?
Show the answer
No. GPIO 2 and GPIO 4 are complementary; the full cycle includes both phases.