The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1
Chapter 6 Physical computing with Scratch and Python 127

THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE


Start by checking that your LED works. Turn your Raspberry Pi so the GPIO header is in
two vertical strips to the right-hand side. Connect one end of your 330 Ω resistor to the first
3.3 V pin (labelled 3V3 in Figure 6-1) using a female-to-female jumper wire, then connect the
other end to the long leg – positive, or anode – of your LED with another female-to-female
jumper wire. Take a last female-to-female jumper wire, and connect the short leg – negative, or
cathode – of your LED to the first ground pin (labelled GND in Figure 6-1).


3V3
GP2
GP3
GP4
GND
GP17
GP27
GP22
3V3
GP10
GP09
GP11
GND
DNC
GP5
GP6
GP13
GP19
GP26
GND

5V
5V
GND
GP14
GP15
GP18
GND
GP23
GP24
GND
GP25
GP8
GP7
DNC
GND
GP12
GND
GP16
GP20
GP21

5 Figure 6-1: Wire your LED to these pins – don’t forget the resistor!


As long as your Raspberry Pi is on, the LED should light up. If it doesn’t, double-check your
circuit: make sure you haven’t used too high a resistor value, that all the wires are properly
connected, and that you’ve definitely picked the right GPIO pins to match the diagram.
Also check the legs of the LED, as LEDs will only work one way around: with the longer leg
connected to the positive side of the circuit and the shorter leg to the negative.
Once your LED is working, it’s time to program it. Disconnect the jumper wire from the 3.3 V
pin (labelled 3V3 in Figure 6-2, overleaf) and connect it to the GPIO 25 pin (labelled GP25 in
Figure 6-2). The LED will switch off, but don’t worry – that’s normal.

Free download pdf