Light Switch

A button is connected to PA0. When pressed (pin goes high), turn on the LED at PA5. When released (pin goes low), turn off the LED.

Your firmware should:

  1. Configure PA0 as input
  2. Configure PA5 as output
  3. Poll PA0 and mirror its state to PA5

Use BSRR (not ODR read-modify-write) to set/clear PA5: a single BSRR write sets or clears the pin atomically, with no read-modify-write window for an interrupt to corrupt. We'll press the button twice during the test.

Loading the interactive arena.