PyRaspBeta

← All practice problems

Raspberry Pi practice problem · LEDs & PWM

Sunrise

EasyBudget $2Python · gpiozero

A wake-up light: an LED on GPIO18 starts off and fades up evenly over 4 s to full brightness, then stays fully on.

"Evenly" means the PWM duty grows in a straight line: about 25 % at 1 s, 50 % at 2 s, 75 % at 3 s.

Tip: change a PWMLED's value in small steps — say 100 steps of 0.04 s.

More in LEDs & PWM