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
Three 270Ω resistors with 5% tolerance (red violet brown gold)
The following diagram shows the components connected to the breadboard, the necessary wirings and the wirings from the Intel Galileo Gen 2 board to the breadboard. The Fritzing file for the...