Accessing the GPIO pins

My main interest in using the RPi is to access the GPIO pins so that I can interface with electronic projects.  For reference here’s the GPIO map from elinux.org:

GPIOs

The pins are all explained in detail at http://elinux.org/RPi_Low-level_peripherals.

So here’s what I did to set up access to the GPIO pins using C and Python.

Install WiringPi

This is a fantastic library written by Gordon Henderson that allows access to the GPIO pins.  It has its own web pages at:

http://wiringpi.com/

To install simply follow the instructions on Gordon’s site.

There are various wrappers for WiringPi so that it can be accessed from other languages.  I’m learning Python so I obtained the wrapper using git:

git clone https://github.com/Gadgetoid/WiringPi2-Python.git

In order to install you need some tools installed on your RPi

sudo apt-get install python-dev python-setuptools swig2.0

Then issue the command from inside the WiringPi2-Python directory:

./build.sh

and it will install.

Configuring I2C

The I2C interface is not activated by default in the Raspbian kernel, follow the adafruit guide to get it up and running:

http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

Install the Adafruit WebIDE

Although not necessary to get your RPi up and running, the WebIDE is a very useful tool for running your programs from any PC on your network.  It stores your projects in the cloud which means that if all goes wrong you’ve got a backup.  The instructions for installation can be found at:

http://learn.adafruit.com/webide/installation

That’s about it, after a couple of hours my Raspberry Pi is back up and running and my GPIO projects are all working.  I will write about the projects in the next post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s