I hope someone can help with this, i've looked at similar Q&A's but haven't found an answer that solves the basic question.

Right, trying to give all the info...

I'm using a first generation B+ board, recently updated using sudo apt dist-upgrade and trying to simply get a LED to light when a button is pressed and not before. Python 3 and Thonny.

import RPi.GPIO as GPIO
import time
GPIO.setmode (GPIO.BCM)
Print ("Done")

The issue is that the LED lights on GPIO.setup line, not the GPIO.output high line where I would expect it to be. I went back to basics and tried just code for the LED as above with the same result.

Any help greatly appreciated.

1 Answer 1


When you set a GPIO to be an output it will be set to the last level it was set to while it was last an output. In your case it was last set high so it is set high when set as an output.

You need to explicitly set the GPIO low if you want it to be low.

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.