O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

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

Creating the Copycat Game

Copycat is a simple game of remembering a sequence of colors and entering them in again. The computer plays a sequence of color flashes and you have to repeat it by pressing buttons. If you are successful, an extra step is added to the sequence and you try to enter that. If you are not successful, you get to have another go. However, three failures in a row ends the game and your score is the length of sequence you managed to get right. You can create a game with lots of different variations on this theme (as you will see later in this chapter), some of which make it fiendishly difficult. You can make two versions of this game, the simple or the deluxe. We’re going to start off with the simple one.

Figure 16-2 shows the schematic of the Copycat game. It’s simply a switch and LED circuit repeated four times. The only differences in each of the circuits are the GPIO to which the switch and LED is attached to and the color of the LED. Notice that the LED resistor is the same value for all the LEDs, as we discussed in the previous section.

The only component we have not mentioned previously here is the push-button switch. Switches can be quite expensive, but one small type of switch is very cheap and is in most sorts of equipment, normally lurking behind plastic molding. This is called a tack switch. It’s square, but the four pins are not on a square grid. There is a long side and short side as far as the pin spacing goes. The two pins on the long side are ...

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