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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.