#!/usr/bin/python
import RPi.GPIO as GPIO
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
# set up GPIO output channel
GPIO.setup(11, GPIO.OUT)
GPIO.output(11, not GPIO.input(11) )
So, if you upgrade to RPIO using
sudo apt-get install python-setuptools
sudo easy_install -U RPIO
Then, you can do
#!/usr/bin/python
import RPIO as GPIO
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
if GPIO.gpio_function(11) is GPIO.OUT :
# this is stupid, but just to trick RPIO
GPIO.setup(11, GPIO.OUT)
GPIO.output(11, not GPIO.forceinput(11))
Traceback (most recent call last):
File "./nu_toggle_17.py", line 12, in
GPIO.output(11, not GPIO.forceinput(11))
RPIO.Exceptions.WrongDirectionException: The GPIO channel has not been set up as an OUTPUT
..
No comments:
Post a Comment