User manual
57
After the LED has achieved its full brightness, a second loop regulates the intensity in the same way but
reverse. This loop counts down from
100 in increments of -2. This cycle iterated until a user stops it with the
key combination
[Crtl]+[C].
except KeyboardInterrupt:
p.stop(); GPIO.cleanup()
The KeyboardInterrupt triggers now also the method stop()of the PWM object. This method stops the
generation of a PWM signal. Then the GPIO ports are reset as already known from past programmes.
6.1.2 Dimming two LEDs independently of one another
A programme time in the Python script is not required for programming the PWM signal, thus several LEDs
can be dimmed independently from one another, as the next experiment shows. Connect an additional LED
via a series resistor to GPIO port 25.
Fig. 6.4: Breadboard assembly to dim two LEDs