How to install wiringPi

To make use of the Raspberry Pi’s gpio pins for hardware testing I nearly always use the wiringPi library to communitcate with the gpio pins. This set of libraries was designed by Gordon at Gordons Projects.

It offers an easy way to utilise the gpio outputs and inputs on the Raspberry Pi.

To install, open a terminal window and type the following:

git clone git://git.drogon.net/wiringPi

Once downloaded, to build the libraries, type the following:

cd wiringPi
./build

That’s it! Easy peasy! Lets now see how it works.

We first need to wire up an LED to our breadboard. See the diagram below for instructions on how to do this:

gpio one led

Gpio One Led Setup

As you can see we have connected the LED to actual pin 11 on the Raspberry Pi. This, in wiringPi terms, is gpio 0. The LED is also connected to ground (GND) via a resistor.

To power the LED all we do is set the pin as an output. Type the following into the terminal:

gpio mode 0 out

Then to light it up type:

gpio write 0 1

The write command sends current to GPIO 0 (1=send power).
To test that power is being sent (if LED doesn’t light up) we can type:

gpio read 0

If the answer is (1) we know that power is being sent through the pin. If the LED is not lit, just remove from the breadboard and change the orientation of the legs (turn it around).

To turn it off simply type:

gpio write 0 0

The write command stops current to GPIO 0 (0=stop power).

Now take a look at my tutorial to make the LED sing and dance: Flash an LED.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>