PyRasp

← All practice problems

Raspberry Pi Pico practice problem · Raspberry Pi Pico

PWM fade

MediumBudget $4MicroPython

An LED on GP13 fades up with PWM. Start at duty 0, then add 1/8 every 0.2 s until the duty is 1.0 (1.6 s). Leave it at full brightness for the rest of the run.

pwm = PWM(Pin(13))
pwm.duty_u16(0)      # 0
pwm.duty_u16(65535)  # full

A 1000 Hz frequency is a good choice for an LED.

More in Raspberry Pi Pico