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)

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)
GPIO.output(21, GPIO.LOW)

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)

1 Answer 1


The gpiozero module always uses Broadcom GPIO numbering to identify a GPIO.

The RPi.GPIO module can use physical pin numbering (BOARD) or Broadcom GPIO numbering (BCM). The physical pin 21 is connected to GPIO 9.

See https://pinout.xyz/

  • I see, thanks for the explanation. Using the BCM mode in my Version 2 code above got it running. Commented Apr 15, 2018 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.