Firing actions when the environment light changes

In previous examples, we worked with PWM to set the brightness level for the red, green, and blue components of an RGB LED. Now, we will add an RGB LED and we will set the brightness level for its three components based on the ambient light detected with the photoresistor. We will wire the RGB LED as we did in the example in which we worked with this component in Chapter 4, Working with a RESTful API and Pulse Width Modulation. We will use the following PWM output pins:

  • Pin ~6 to connect the anode pin for red LED
  • Pin ~5 to connect the anode pin for green LED
  • Pin ~3 to connect the anode pin for blue LED.

We need the following additional parts to work with this example:

  • One common cathode 5mm RGB LED ...

Get Internet of Things with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.