O'Reilly logo

Internet of Things with Python by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required