Element 14 Raspberry Pi User Manual page 27

Table of Contents

Advertisement

We're going to use the
is part of WiringPi . You can find out more
about this from the website: bit.ly/RP8UKJ.
The software comes as source code, so
we'll have to unzip it and compile it with:
tar xvf wiringPi.tgz
cd wiringPi/wiringPi
make
sudo make install
cd ../gpio
make
sudo make install
We'll also use
, so install it with:
bc
sudo apt-get install bc
Now, that's enough about software – on
with the hardware! Just a quick word of
warning before we start: it is possible
to break your Pi by connecting the
wrong wires together, so make sure you
double-check before powering up.
Raspberry Pi User Guide.indd 27
gpio
program, which
The circuit for this is very simple – you
just have to connect each output to
the positive leg of an LED, then the
negative leg of the LED (shorter) to a
1 KOhm resistor, and finally the other leg
of the resistor to the common ground.
See figures 1, 2 and 3 for details.
Once you have your fully-set-up board
connected to your Pi, you can make things
happen. To start with, we'll just use the
final pin. This is pin 7 (the layout of the pins
doesn't follow a numbering pattern). Open
up a terminal, and set it to output with:
gpio –g mode 7 out
Then you can turn it on with:
gpio –g write 7 1
and off again with:
gpio –g write 7 0
If you're like us, you'll do that repeatedly until
the novelty of it wears off. Once it has, you're
ready to run the script. It contains four parts.
PIN PIN
PIN
PIN
PIN
PIN PIN
PIN
PIN
PIN PIN
PIN
PIN
PIN
PIN
PIN PIN
PIN
PIN
PIN PIN
PIN
PIN
PIN
Figure 2. Connect
the bread board to
these pins. We used
commercially-
available single-pin
connectors, but you
could also solder
connectors on, or use
an old IDE cable.
27
08/07/2014 14:44

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Element 14 Raspberry Pi

Table of Contents