File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,40 @@ Alternatively::
5959 :ref: `keep-your-script-running ` for more information.
6060
6161
62+ LED with variable brightness
63+ ============================
64+
65+ Any regular LED can have its brightness value set using PWM (pulse-width-modulation).
66+ In GPIO Zero, this can be achieved using :class: `PWMLED ` using values between 0
67+ and 1::
68+
69+ from gpiozero import PWMLED
70+ from time import sleep
71+
72+ led = PWMLED(17)
73+
74+ while True:
75+ led.value = 0 # off
76+ sleep(1)
77+ led.value = 0.5 # half brightness
78+ sleep(1)
79+ led.value = 1 # full brightness
80+ sleep(1)
81+
82+
83+ Similarly to blinking on and off continuously, a PWMLED can pulse (fade in and
84+ out continuously)::
85+
86+ from gpiozero import PWMLED
87+ from signal import pause
88+
89+ led = PWMLED(17)
90+
91+ led.pulse()
92+
93+ pause()
94+
95+
6296Button
6397======
6498
You can’t perform that action at this time.
0 commit comments