The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

146 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE


Python project: Quick Reaction Game
Now you know how to use buttons and LEDs as inputs and outputs, you’re ready to build an
example of real-world computing: a two-player quick-reaction game, designed to see who
has the fastest reaction times! For this project you’ll need a breadboard, an LED and a 330 Ω
resistor, two push-button switches, some male-to-female (M2F) jumper wires, and some male-
to-male (M2M) jumper wires.
Start by building the circuit (Figure 6-7): connect the first switch at the left-hand side of your
breadboard to the GPIO 14 pin (labelled GP14 in Figure 6-7), the second switch at the right-
hand side of your breadbOard to the GPIO 15 pin (labelled GP15), the LED’s longer leg to the
330 Ω resistor which then connects to the GPIO 4 pin (labelled GP4) of the Raspberry Pi, and
the second legs on all your components to your breadboard’s ground rail. Finally, connect the
ground rail to the Raspberry Pi’s ground pin (labelled GND).

3V3GP2GP3GP4GNDGP17GP27GP223V3GP10GP09GP11GNDDNCGP5GP6GP13GP19GP26GND

5V5VGNDGP14GP15GP18GNDGP23GP24GNDGP25GP8GP7DNCGNDGP12GNDGP16GP20GP21

5 Figure 6-7: Wiring diagram for the Quick Reaction Game
Free download pdf