Using the GPIO pins on a Raspberry Pi

In addition to being a serviceable single board computer, the Raspberry Pi also has a header full of GPIO pins at your beck and call. [Tedbot] sent in a great tutorial on using these pins with Python, Bash, and C.

The GPIO pins on the Raspi are arranged in a 2×13 header. Until Sparkfun manages to manufacture a decent Raspi protoboard, the easiest way to break these pins out is with an old IDE ribbon cable. After plugging the other end into a breadboard, [Tedbot] had an easily accessible set of Raspi pins.

To control these pins, [Tedbot] found two libraries: the first is WiringPi that implements a C-style, Arduino-like programming environment on the Raspi. The second is the RPi.GPIO Python package. Since the Raspi runs Linux, and everything in Unix is a file, [Tedbot] used a shell script to blink a LED.

One word of warning if you’re building a board to extend the capabilities of the Raspi: these pins aren’t 5 V tolerant, so you’ll need to throw in a buffer or level converter when building a Raspi circuit.

Edit: Adafruit is releasing a Pi Plate prototyping board in a few weeks. Neat, huh?

17 thoughts on “Using the GPIO pins on a Raspberry Pi

    1. Oops, I mean they’re testing it. They also have a nice transparent acrylic box.

      Don’t know if SparkFun is working on anything.

  1. I just want to know if anyone has an idea of how to connect an IR module such as TSOP 1738 to the board using the GPIO and LIRC drivers.

    1. Dragon,

      The RPi doesn’t have an ADC, so you’d have to use an external one connected to SPI or I2C. Then you’d have to write code to interface with that to take readings, then you’d have to interface with LIRC. So, if you just want to read from an IR remote, you’d probably be better of using an off-the-shelf USB module.

      1. Oh! Whoops, I didn’t look closely enough; I hadn’t realized it was a digital device. Nevermind about the ADC! But you’d still have to write the code to demodulate the output and get it talking to LIRC.

    1. It would be great to have their designs, but the schematics are only part of the equation. The supply chain is the real hard part; even with the schematics there’s no way we’d be able to get the price close to $25.

  2. I thought the Raspberry Pi company went bankrupt or default or something, this things actually exist?

    (Sarcasm above.)

  3. > the easiest way to break these pins out is with an old IDE ribbon cable

    Seriously?
    IDE ribbon cables have over half their conductors as ground, including a few that are mapped to actual pins, and all those ground conductors are connected via a conductor in each of the connectors.
    Plug an IDE cable in to anything that isn’t designed with those ground cables in mind and you will short some of your pins… which is usually a good way to annoy your hardware.
    There are also a couple of pins that aren’t connected at all in one of the connectors, and a keying pin that is blocked up just to make your life fun.

    http://en.wikipedia.org/wiki/Parallel_ATA#Differences_between_connectors_on_80-conductor_cables for full details.

    1. Huh, never knew that. Crazy. In this case, it’s a totally plain IDC ribbon cable connector, no special wiring. Obviously safest to crimp your own. I tested all the pins for funny business before powering anything (3 times), as I always do. I’ll add this information to the tutorial. Thanks!

    2. The newer higher speed IDE 80 wire cable is the one that has every second conductor grounded, the older 40 wire cable does not. And it’s easy to tell the difference – just count the conductors in the ribbon cable!

  4. I want to know if its possible to connect an old eide/pata cd/DVD drive up to my raspi to play movies and such.
    Any suggestions?

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