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. 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.

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

    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. 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!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.