Skip to content
09micro:bit · MakeCode 25 minutes

Breathing LED

Fade the P0 LED up and down with analog write.

Breathing LED project
Illustration of the finished idea. Build from the diagram and connection table, not the photo.

Lesson goal: Use analogWritePin with values 0 to 1023 to fade the LED smoothly.

Open MakeCode

Section 1

Understand

  • PWM
  • duty cycle
  • 0..1023 range
  • PWM period
  • 1analog write sets brightness from 0 to 1023.
  • 2Count up then down to fade the LED in and out.
  • 3micro:bit uses 0–1023, not the Pico's 0–65535.

Safety first

  • Unplug the USB cable before you add, move or remove any wire. Plug back in only after an adult or you have re-checked every connection against the table.