The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

Tutorial


raspberrypi.org/magpi The Official Raspberry Pi Projects Book 103


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

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


MAKE A WHOOPI CUSHION


Making the Whoopi cushion
Cut a circle from the cardboard to fit the centre of the
‘eating’ side of each paper plate. Tape or stick squares
of foil onto the cardboard. These are your contacts:
when they touch, they will complete a circuit. Using
some copper tape, connect the foil to the edge of the
plate. Chop the sponge up into cuboid chunks and
glue them around the foil on one of the plates: this
will stop the foil squares touching each other until
someone sits on the plate. It should look something
like Figure 1.
Put the two plates together so that the foil pieces
are on the inside and facing each other. Offset the
paper plates so that the copper tape sections are
not touching.
You now have a ‘cushion’ made of two plates. You
can tape the plates together, or you might choose to
use bulldog or paper clips so that you can test that
your cushion works correctly, and easily debug any
hardware problems.


Connect the Whoopi cushion to the Pi
Plug one header lead (it doesn’t matter which) onto
a ground (GND) pin on the Pi (refer to Figure 2). Plug
the other wire onto the GPIO 2 pin (Figure 3, overleaf)
and then clip a crocodile clip cable to one of the paper
plates’ copper tape sections. Connect the other end of
the crocodile clip cable to the male pin of one of the
connected jumper wires (Figure 4). Repeat these last
two steps to connect the other plate to your Raspberry
Pi. Your setup should look similar to Figure 5.


Test the sound
That’s the hardware complete. Now for the software!
We’re going to use Python. Don’t worry if you haven’t
used it before: just follow the instructions and you’ll
pick it up. You’ll be using the command line to enter
commands. To do this you’ll need to open a terminal
window by clicking on the terminal icon: it looks like a
computer screen, and is found three icons along from
the Menu button on your desktop.

Figure 1 It looks a bit
like some futuristic
tech. We’ll use it to
make farting sounds

Figure 2 If you have
an older Raspberry
Pi model you'll
only have 26 pins,
but they have the
same layout
Free download pdf