I read here that I could toggle the state of a GPIO pin set to output in Python using the following command:
GPIO.output(LED, not GPIO.input(LED))
where LED
is the pin value. I can turn the LED on using the following code:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
LED = 17
GPIO.setup(LED,GPIO.OUT)
GPIO.output(LED,True)
But when I try GPIO.output(LED, not GPIO.input(LED))
, the following error is thrown.
RPi.GPIO.WrongDirectionException: The GPIO channel has not been set up or is set up in the wrong direction
Am I supposed to set up the GPIO channel differently from above or is the site I referenced posting incorrect information?