Chapter 7. Light Up Guessing Game
- Simplifying and improving your code with more thoughtful design and use of functions
- Building a circuit to control a special LED (light bulb) that can make and combine red, green, and blue light
- Adding together colors of light to create new colors
- Making your Pi come alive by having it respond using different colored light
Your Raspberry Pi has a unique ability to interact with the world around it. In the last chapter, you made lights blink based on a programmed pattern. Nice, but that isn’t truly interactive, because the Pi always blinks a pattern that you program it to do. In this chapter, let’s see if you can create an interactive project that responds to you through its GPIO pins. You’ll draw on what you’ve learned about conditional logic (if/elif/else) to have your Pi make decisions and respond. As you did in earlier chapters, you’ll need to gather input, use loops, and apply a few other programming techniques to get it done.
You’re making a Light Up Guessing Game, but not just any one: this game will illuminate a small light called an RGB (stands for red, green, blue) LED, which can make any color. You’ll use your Pi, breadboard, and electrical parts, along with a program you’re going to write. Your Pi will let the player know if they’re correct by flashing the RGB in different colors if their guess is too high or too low.