3v3 Power

The 3v3, 3.3 volt, supply pin on the Pi has a max current draw of 50 mA, enough to power a couple of LEDs but not much more.

You should use the 5v0 supply instead, and use a regulator if you need 3v3.


BCM pin 0 on Rev 1 board and pin 2 on Rev 2 board. WiringPi pin 8. Ladder Board Small Green LED.

It's easy to get started writing a digital HIGH or LOW to a GPIO pin, but you've got to remember a few things:

  • Run your script as root
  • Set your pin's mode to OUTPUT (1)

Assuming you've installed WiringPi2-Python ( pip install wiringpi2 ) then try pasting the following into a .py file:

import wiringpi2 as wiringpi
HIGH = 1
LOW = 0

Then run it with:

sudo python


BCM pin 1 on Rev 1 board and pin 3 on Rev 2 board. WiringPi pin 9. Ladder Board Small Red LED.

require 'wiringpi2'
HIGH = 1
LOW = 0
io =


BCM pin 4. WiringPi pin 7. Quick2Wire I2C Interrupt. Ladder Board LED Blue 2.



BCM pin 17. WiringPi pin 0. Quick2Wire Push Button. Ladder Board LED Red 1.


BCM pin 21 on Rev 1 board and pin 27 on Rev 2 board. WiringPi pin 2. Ladder Board LED Yellow 1.


BCM pin 22. WiringPi pin 3. Ladder Board LED Yellow 2.

3v3 Power


BCM pin 10. WiringPi pin 12. Ladder Board Button 3.

Connect to the MOSI pin of an ATmega328, Arduino Pin 11, for programming with AVRDude. Make sure your ATmega328 is powered by a 3.3v supply. If you're using 5v, make sure to use a logic-level converter.


BCM pin 9. WiringPi pin 13. Ladder Board Button 4.

Connect to the MISO pin of an ATmega328, Arduino Pin 12, for programming with Gordon's modified AVRDude. Make sure your ATmega328 is powered by a 3.3v supply. If you're using 5v, make sure to use a logic-level converter.


BCM pin 11. WiringPi pin 14.

Connect to the SCK pin of an ATmega328, Arduino Pin 13, for programming with Gordon's modified AVRDude. Make sure your ATmega328 is powered by a 3.3v supply. If you're using 5v, make sure to use a logic-level converter.


5v Power

The 5v0 power pins are connected directly to the Pi's power input and will capably provide the full current of your mains adaptor, less that used by the Pi itself.

Don't be disuaded by what sounds like a measly low voltage. You can do a lot with this! I regularly use mine to power Arduinos and have even run a small Electroluminescent wire inverter right off the 5v pin!

5v Power

This pin is exactly the same as its 5v companion. Two is better than one, right? There's nothing much more to say about the 5v pin.


The Revision 2.0 Raspberry Pi turns all the original "do-not-connect" pins into additional ground. Pay careful attention to where these are, because connecting any outputs or voltage supplies directly to ground will not to your Pi any favours!


BCM pin 14. WiringPi pin 15.

This pin doubles up as the UART transmit pin, TXD.

UART is extremely useful if you want to get into Piduino ( a delightful blend of Arduino and Raspberry Pi ) territory. Hook the RXD up to the Arduino's TXD via a 3.3v <-> 5v logic level converter, and the TXD up to the Arduino's RXD. Personally I avoid using a logic level converter and run my breadboard Arduino on 3.3v.


BCM pin 15. WiringPi pin 16.

This pin doubles up as the UART recieve pin, RXD.


BCM pin 18. WiringPi pin 1. Quick2Wire LED. Ladder Board LED Red 2.



BCM pin 23. WiringPi pin 4. Ladder Board LED Green 1.


BCM pin 24. WiringPi pin 5. Ladder Board LED Green 2.



BCM pin 25. WiringPi pin 6. Quick2Wire SPI Interrupt. Ladder Board LED Blue 1.

GPIO 8 (CE0)

BCM pin 8. WiringPi pin 10. Ladder Board Button 2.

Connect directly to the Reset (RST) pin of an ATmega 328 for programming with Gordon's modified AVRDude. Make sure your ATmega328 is powered by a 3.3v supply. If you're using 5v, make sure to use a logic-level converter.

GPIO 7 (CE1)

BCM pin 7. WiringPi pin 11. Ladder Board Button 1.

Pinout! For the Revision 2.0 Raspberry Pi

Pinout isn't meant to be printable, or a quick reference. This is a comprehensive, starter guide to learning about your Raspberry Pi's GPIO pins and how to start using them with WiringPi and it's language-specific libraries.

WiringPi uses its own pin numbering scheme, here you'll learn how WiringPi numbers your GPIO pins, what those pins do and how to do shiny things with them from within Python or Ruby.

Getting started with WiringPi

Before you start tinkering with software, you should pick up some hardware. You can build out your own circuits on a breadboard, but for a simple introduction to soldering, and a basic board to demonstrate both input and output I highly recommend the inexpensive Raspberry Pi Ladder Kit.

WiringPi, the Arduino-like GPIO library for the Pi, is available in C right from Gordon's git repository, Python, Ruby and even Perl and PHP to a lesser extent.

Installing to Python couldn't be easier, just:

sudo pip install wiringpi2

Note the 2 on the end? That's the all new, shinier WiringPi!

5v Power

The 5v power pins, two of them, provide your project with any current your power adaptor can muster minus that which is used by the Pi itself.

5v power is great for regulating down to 3.3v, which you can then use to power an ATmega that's logic-level compatible with your Pi.

If you need more than 5v, driving motors for example, you'll have to find your power elsewhere!

3.3v Power

At a measly 50mA max current, the 3.3v pin on the Raspberry Pi isn't terribly useful, but it's enough to light an LED or two.

0v Ground

When powering a project from the Pi, the Ground pin completes your circuit.

If you want to memorise this pinout, you should forget the ground pins spaced out around the GPIO header and focus just on the one below the 5v pins and pin 25.

UART - Universal Asynchronous Receiver/Transmitter

The 2 UART pins in WiringPi are: 15, 16

UART is a handy, straight forward way to interface an Arduino ( or bootloaded ATmega ) with your Pi. You must, however, be careful with logic-levels between the two devices: the Pi is 3.3v and the Arduino is 5v. Connect the two and you might conjure up some magic blue smoke.

Personally I'm a fan of building out a Arduino Bootloaded ATmega 328 circuit on a breadboard with a voltage regulator to take the Pi's 5v line and convert it to 3.3v. The ATmega 328 seems to run quite happily at 3.3v using a 16Mhz crystal and you'll then have an Arduino clone with 3.3v logic.

The following python example opens the Pi's UART at 9600baud and puts 'hello world'

import wiringpi2 as wiringpi
serial = wiringpi.serialOpen('/dev/ttyAMA0',9600)
wiringpi.serialPuts(serial,'hello world!')

GPIO - General Purpose Input/Output

The 8 GPIO pins in WiringPi are: 0, 1, 2, 3, 4, 5, 6, 7

SPI - Serial Peripheral Interface

Known as the four-wire serial bus, SPI lets you daisy-chain multiple compatible devices off a single set of pins by assigning them different addresses.

A simple example of an SPI peripheral is the MCP23S17 digital IO expander chip Note the S in place of the 0 found on the I2C version. Using it in WiringPi2 is a doddle:

import wiringpi2 as wiringpi
HIGH = 1
SPI_ADDR = 0x20
# 16 pins including the starting pin
mcp23S17pins = range(PIN_BASE,PIN_BASE+15)
for pin in mcp23S17pins:

You can also use the SPI port to "Bit-Bang" an ATmega 328, loading Arduino sketches onto it with Gordon's modified version of AVRDude.

Hook up you Pi's SPI port to that of your ATmega, and power the ATmega from the 3.3v pin on the Pi. Make sure you're not running any SPI device drivers, and run "avrdude -p m328p -c gpio" to verify the connection.

See the individual pins to learn how to connect up your ATmega.

I2C - Inter Intergrated Circuit

The 2 I2C pins in WiringPi are: 8, 9

A simple example of an I2C peripheral is the MCP23017 digital IO expander chip on the Hobbytronics Breakout, and Quick2Wire IO Expander Addon Board. Using it in WiringPi2 is a doddle:

import wiringpi2 as wiringpi
HIGH = 1
SPI_ADDR = 0x20
# 16 pins including the starting pin
mcp23017pins = range(PIN_BASE,PIN_BASE+15)
for pin in mcp23017pins:

You can also use generic I2C, to access devices not supported with a specific driver:

import wiringpi2 as wiringpi
i2c = wiringpi.I2C()
device = i2c.setup(0x20)

Raspberry Pi Ladder Board

The inexpensive Raspberry Pi Ladder Kit is a great way to get started with GPIO tinkering.

It connects 12 LEDs and 4 buttons directly to the GPIO pins, making it extremely easy to start programming. Using the pins on the left, you simply set 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9, the LEDs, to OUTPUT (1) and 10,11,12,14, the buttons, to INPUT (0) and start reading/writing.

In practice, it's actually a little more complicated than this. The buttons all need their pull up/down switched to PUD_UP/UP (2), because pressing a button on the ladder board pulls that pin down to ground.

The code below should get you started:

import wiringpi2 as wiringpi
LOW = 0
HIGH = 1
BUTTONS = [13,12,10,11]
LEDS = [0,1,2,3,4,5,6,7,8,9]
PUD_UP = 2


for button in BUTTONS:

for led in LEDS:

while 1:
    for index,button in enumerate(BUTTONS):
        button_state = wiringpi.digitalRead(button)
        first_led = LEDS[index*2]
        second_led = LEDS[(index*2)+1]
        #print str(button) + ' ' + str(button_state)

The button locations and their corresponding pin numbers also don't correspond with those of the LEDs so we have to pair up the buttons accordingly for a basic example. Finally, never forget to call wiringpi.wiringPiSetup() or nothing much will happen!

Raspberry Pi WiringPi

WiringPi is an attempt to bring Arduino-wiring-like simplicity to the Raspberry Pi. The goal is to have a single common platform and set of functions for accessing the Raspberry Pi GPIO across muliple languages. WiringPi is a C library at heart, but it's available to both Ruby and Python users who can "gem install wiringpi" or "pip install wiringpi2" respectively.

Python users note the 2 on the end, the WiringPi2-Python library finally brings a whole host of existing WiringPi functionality to Python including brand new features from WiringPi 2.

For more information about WiringPi you should visit the official WiringPi website.

PiBorg LedBorg RGB LED Board

The PiBorg LedBorg is an ultra-bright RGB LED board for the Raspberry Pi. It has its own driver, so you don't need to drive it manually.

If you want a much, much wider range of colours, though, you can drive it manually using softPwm in WiringPi. The pin assignments for this are as follows:

WiringPi pin 0: Red LED
WiringPi pin 2: Green LED
WiringPi pin 3: Blue LED

This is easy using WiringPi in Python:

import wiringpi2 as wiringpi

Geekroo Clockatoo Clock Board With buzzer

The Clockatoo buzzer is available on WiringPi pin 7, GPIO pin 4.

The GeekRoo Clockatoo is a great little board combining a battery-backed up real-time clock, a 4 digit, 7 segment display and a buzzer into one package.

GeekRoo's own instruction manual gets you started with the clock itself, but doesn't tell you how to use the buzzer.

WiringPi's softTone does a great job of pulsing the buzzer at a variety of annoying ( or alerting ) speeds, try this for a simple alert tone:

import wiringpi2 as wiringpi

The second parameter for softToneWrite is the frequency, drive it higher and the alarm sound will become steadily more irritating until you're sure to wake up!

ATmega 328p / Arduino over SPI

Did you know that your Pi could power and program an ATmega 328p/Arduino directly, with nothing but a few wires, a breadboard, a 16Mhz crystal oscillator and some 22pF capacitors?

Read my complete Pico PiDuino tutorial to get started for just over £5

You can also go it alone and try this Arduino-compatible kit from Phenoptix.

You'll also need to install Gordon's modified AVRDude.

Connect 8/CEO to your ATmega's Reset/RST pin, 9/MISO to its MISO pin (D12), 10 to its MOSI pin (D11) and 11/SCLK to its SCLK pin (D13).

Power your ATmega with the 3.3v and GND pins from your Pi, and you're good to go.

Make sure you have no rogue SPI device drivers running and check it's connected correctly using:

avrdude -p m328p -c gpio

To get started compiling Arduino sketches from the command line:

sudo apt-get install arduino arduino-mk

This basic Makefile should get you started. Create a basic sketch, name it mysketch.ino and run:

export BOARD=atmega328
avrdude -p m328p -c gpio -e -U flash:w:build-cli/Arduino.hex