Raspberry Pi practice problem · LEDs & PWM
Staircase
EasyBudget $2Python · gpiozero
Dim an LED on GPIO18 in steps using PWM, one step per second:
- 25 % from 0 to 1 s
- 50 % from 1 to 2 s
- 75 % from 2 to 3 s
- 100 % from 3 to 4 s
- back to 25 % at 4 s, and repeat
Tip: a PWMLED takes a value from 0 (off) to 1 (full).