Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
You might be wondering about the setmode and BCM in the irst line of the
Step 2. There are two ways— modes —of numbering the GPIOs within RPi.
GPIO— BCM and BOARD . It is important that you set the mode ( setmode ) you
wish to use in your Python code. BOARD means that the numbers passed into
the GPIO functions refer to the pin numbers of the header on the Raspberry Pi.
BCM means that numbers passed into the GPIO functions refer to what the
BroadCoM chip uses for its GPIOs (which are different from the actual pin num-
bers on the RPi header).
The exercises in this adventure use the BCM numbers, which is why you needed
to include GPIO.setmode(GPIO.BCM) at the start of your GPIO program. To
use the BOARD mode, you would write GPIO.setmode(GPIO.BOARD) .
Connecting the LEDblink
Components
Before running your program to make the LED blink, you need to assemble the elec-
tronic components and connect them to the Raspberry Pi GPIO pins. Figure 8-8 shows
the Raspberry Pi on the left and a breadboard on the right. Use this diagram and the
following steps to help you connect the right cables and components in the circuit.
As noted earlier, these instructions are written for a Rev 2 board. If you have a
Rev 1, you must adjust the instructions based on the Rev 1 layout diagram. You
could cause permanent damage your Raspberry Pi if you connect circuits to the
GPIO pins incorrectly.
1. Start by plugging a female-to-male jumper cable from GPIO pin 24 of your
Raspberry Pi to the A10 hole on your breadboard (the red cable in Figure 8-8). It
helps to use diferent coloured wires. he jumper cable will easily it onto the
pins of your Raspberry Pi on one end, and into the holes on the breadboard.
Make sure that you gently push them down as far as they will go to make a
secure connection.
2. Next, plug another female-to-male jumper cable from a ground pin, sometimes
represented as GND on Raspberry Pi GPIO diagrams (the blue cable). On a Rev 2
Raspberry Pi board, the third pin from the top on the outside strip is a ground
pin (see Figure 8-8). Remember to use Dr Monk's Raspberry Leaf so that you
know which pins are which!
Search WWH ::




Custom Search