I'm trying to turn on an LED and it was trivial with the gpiozero
library. The following works just as expected.
# Version 1 (working)
import gpiozero
import time
led = gpiozero.LED(21)
led.on()
time.sleep(20)
led.off()
However, when I tried to switch over to RPi.GPIO
, I can't get the same pin to go High.
# Version 2 (not working)
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD) # Use board pin-out instead of Broadcom
GPIO.setup(21, GPIO.OUT)
GPIO.output(21, GPIO.HIGH)
time.sleep(20)
GPIO.output(21, GPIO.LOW)
GPIO.cleanup()
When I execute Version 2 above and use a multimeter, I see that Pin 21 is approximately 0 V, when I expect it to be High. There are no errors printed. Did I port the code over correctly to use RPi.GPIO
?
Pi 3 Model B running Raspbian GNU/Linux 9 (stretch)