First thing was to install the Python compiler. I didn't do this at first and when trying to compile the RasPi GPIO library I got an error (said it couldn't find Python.h)! Looking to the forums I found the following command to install Python:
sudo apt-get install python-dev
Then according to our trusty friends at TheMagPi issue #2 (page 13), I downloaded the RPi GPIO file using the Midori browser from http://pypi.python.org/pypi/RPi.GPIO (to my home/pi directory) and then used these commands to unzip, untar and then compile it (use sudo if needed):
gunzip RPi.GPIO-0.3.0a.tar.gz
tar -xvf RPi.GPIO-0.3.0a.tar
cd RPi.GPIO-0.3.0a
sudo python setup.py install
Then after a few minutes we have it all installed. Then using nano editor "nano mytest.py", I created my first python program to turn on the GPIO 11 as follows:
#!/usr/bin/python
import time
import RPi.GPIO as GPIO
# to use Raspberry Pi board pin numbers GPIO.setmode(GPIO.BOARD) # set up the GPIO channels - one output GPIO.setup(11, GPIO.OUT)
count = 0
while (count < 10):
print "count", count
GPIO.output(11, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(11, GPIO.LOW)
time.sleep(0.5)
count = count + 1Running the program was basically just running "sudo python mytest.py". I hooked up the GPIO 11 pin 11 from my RasPi to the + rail on my breadboard, and had a resistor and LED in series, then ground to pin 6. When the GPIO is set to high it output 3.3v which was enough to turn on the LED. Success!