Traffic Light

Build a traffic light controller using three GPIO pins!

Real traffic lights cycle through a strict sequence: green, yellow, red. Your job is to implement this on three LEDs connected to GPIO Port A:

  • PA0 = Red
  • PA1 = Yellow
  • PA2 = Green

The correct cycle is: GREEN on → GREEN off, YELLOW on → YELLOW off, RED on → RED off. Then repeat for a total of 2 full cycles.

Only ONE LED should be on at any time. When you turn on the next color, the previous color must already be off. Order matters: this is a state machine, not just blinking.

Key concepts:

  • Configuring multiple GPIO pins as outputs
  • Driving multiple pins on the same port independently
  • State machine sequencing (only one state active at a time)
  • Bit manipulation on a shared register without clobbering other pins

Loading the interactive arena.