Mixing multiple colors

Until now, we have only displayed a single color at a time on one or more of the LEDs. If you consider how the circuit is wired up, you might wonder how we can get one LED to display one color and another a different one at the same time. The simple answer is that we don't need to-we just do it quickly!

All we need to do is display one color at a time, but change it back and forth, so quickly that the color looks like a mix of the two (or even a combination of the three red/green/blue LEDs). Fortunately, this is something that computers such as the Raspberry Pi can do very easily, even allowing us to combine the RGB elements to make multiple shades of colors across all five LEDs. Perform the following steps to mix the ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition 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.