I'm testing out some code from the Raspberry Pi User Guide from page 195, modified so the user can end the script a bit more gracefully.
Code: Select all
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
LED_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
loopcontrol = 1
while loopcontrol == 1:
GPIO.output (LED_PIN, True)
time.sleep(2)
GPIO.output (LED_PIN, False)
loopcontrol = int(raw_input("Press 1 to loop again: "))
pi@raspberrypi ~ $ sudo python gpiooutput.py
Traceback (most recent call last):
File "gpiooutput.py", line 9, in <module>
GPIO.setup(LED_PIN, GPIO.OUT)
File "/usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.2.0-py2.7.egg/RPi/GPIO/__init__.py", line 103, in setup
f.write(id)
IOError: [Errno 16] Device or resource busy
pi@raspberrypi ~ $
If I change LED_PIN to another number, say 23, and move my circuit appropriately, it runs fine. Any thoughts?
Thanks for the help!