If power is supplied to the Pi then the LED will be on by default. I've got the LED connected to GPIO pins [4, 6] and the script can not turn it off. I've switch the cables around and that's resulted in the same LED behavior.

Here's the code:

from gpiozero import LED
from time import sleep

i = 0

while True:
    red = LED(i)
    print("Attempting to turn off: ", i)
    if i > 30:
  • 1
    Physical pin 4 is not a GPIO pin. It's a 5V pin and cannot be switched. See pinout.xyz – Dirk Apr 25 at 17:57
  • Connecting from 4 to 1 has wielded the same result? Am I still interpreting things incorrectly? – J_is_for_Jam Apr 25 at 18:28
  • 1
    Pin 1 isn't a GPIO either. Look for a pinout diagram, choose a GPIO pin and connect to that. – Mark Smith Apr 25 at 18:49
  • Thank you! That's got everything working as intended. Thanks both of you :) – J_is_for_Jam Apr 25 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.