I just recently purchased Raspberry Pi 2 model from Canakit. It had pre-installed Raspbian OS. When I started my GPIO programming I noticed all GPIO pins are set High or Low from the start. There value cannot be changed via a program in Pyhton. I have used RPi.GPIO library to modify the signals on pins but no effect.

import RPi.GPIO as GPIO
GPIO.setup(7, GPIO.OUT)
GPIO.output(7, GPIO.LOW)

After running this pin number 7 is High as LED is lit.

  • what code did you run? Please edit your question and include your code. Did you run it with sudo? How do you know it doesn't work? Did you get an error message? Sep 13, 2015 at 16:30
  • We are going to need to see a photo(s) of the connections on both the board and the LED. Sep 13, 2015 at 16:51
  • 1
    Add a time.sleep(10) before the cleanup. The cleanup sets the pin back to be an input and the GPIO's internal pull-up is probably enough to light the LED.
    – joan
    Sep 13, 2015 at 16:57
  • @joan I am going to reopen this so you can post an answer. Sep 13, 2015 at 16:57
  • @SteveRobillard It may be irrelevant. I'd wait on the poster.
    – joan
    Sep 13, 2015 at 16:59

1 Answer 1


Your code sets the pin as a low output, but GPIO.cleanup() will reset all pins to their default state, which to prevent accidental damage is as an input.

An input pin without any actual input is in neither a high nor low state -- it's in a third state known as floating or hi-Z. Testing the state using binary logic will indicate either high or low; anecdotely on the pi this is usually high.

Of course, in this case the pin is connected to an LED which is presumably connected to ground, but as joan points out, internal pull-ups may play a role in this.

The actual voltage will not be as high as an output pin set to high, but it will be enough to light an LED, albeit not as brightly. This is why when you boot the pi with an LED attached to an input, it may glow slightly by default.

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.