RPi using the GPIO. There are lots of interesting articles where people is doing the same, but you won't get the same feeling that I have until you test it by yourself. This application processor board is extremely delicate and you need the get used to its I/O, typical voltage values (3.3V), maximum current (8-11mA), etc. Few basic things that will help you not to burn the RPi (connect resistors after every LED, etc). My example is quite simple but with academical purposes and I'm sure it will inspire others. I'm using the slice of a pi extension board where you can easily get the connectors for GP0-GP7 outputs and lit some LED's programmatically.
Material (apart from your RPi):
First thing is to correctly identify the GP Inputs/Outputs from the Slice of Pi (GP0 to GP7 pins). Here are my findings and the correct pin numeration:
GPIO Slice of Pi
Pin 11 GP0
Pin 12 GP1
Pin 13 GP2
Pin 15 GP3
Pin 16 GP4
Pin 18 GP5
Pin 22 GP6
Pin 07 GP7
As you can see, they are not in order, so you need to spend time looking for the right pins. I still need to identify all the other pins but I'll get to it.
The following code is just lighting up 8 LED's using 8 GPIO pins as outputs. Each pin is connected to a 220 ohm resistance plus a red LED and all terminations to GND.
import RPi.GPIO as GPIO import time from array import * GPIO.setmode(GPIO.BOARD) #Set up GPIO pins #extension board pin name GPIO.setup(7, GPIO.OUT) #GP7 GPIO.setup(11, GPIO.OUT) #GP0 GPIO.setup(12, GPIO.OUT) #GP1 GPIO.setup(13, GPIO.OUT) #GP2 GPIO.setup(15, GPIO.OUT) #GP3 GPIO.setup(16, GPIO.OUT) #GP4 GPIO.setup(18, GPIO.OUT) #GP5 GPIO.setup(22, GPIO.OUT) #GP6 #Set up naming for RPi extension board GPIOArray = array('i', [11, 12, 13, 15, 16, 18, 22, 7]) wtime = 0.01 while True: for i in range (0,7): GPIO.output(GPIOArray[i], GPIO.HIGH) print "Output %d value is %r" % (GPIOArray[i], 1) time.sleep(wtime) GPIO.output(GPIOArray[i], GPIO.LOW) print "Output %d value is %r" % (GPIOArray[i], 0) time.sleep(wtime) #slowing the flashing wtime = wtime + 0.01