I have an LED connected to pin 11 on the Raspberry Pi header, (also known as BCM/GPIO pin 17, and GPIO0). I have installed the Raspberry Pi Python library according to these instructions.
Attempt 1
I installed RPi.GPIO
and used the following code from eLinux. I see an error that 'setmode' is not an attribute of the GPIO library.
sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BOARD)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setmode'
Attempt 2
I used a different tutorial, yet I receive the following error:
sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.setup(17, GPIO.OUT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.1.0-py2.7.egg/RPi/GPIO/__init__.py", line 61, in setup
id = _GetValidId(pin)
File "/usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.1.0-py2.7.egg/RPi/GPIO/__init__.py", line 52, in _GetValidId
raise InvalidPinException
RPi.GPIO.InvalidPinException
I am able to turn on the LED using the GPIO utility:
gpio write 0 0
I have an earlier revision Raspberry Pi.
cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2708
Revision : 0003
Serial : 00000000396bd5ea
Why have I been unsuccessful in turning on an LED from Python?
Additional Resources