I'm reading a value on a GPIO pin (0/1) with bash (wiringPI). Everything worked fine until now. I hooked up a button that I pressed and the raspberry read the value 1 and then 0 when I released it. But now sometimes I only get a 0 if there is absolutely nothing connected to the GPIO. When I connect something to it (even if it's just a wire with nothing on the other end) I'm getting sometimes 0 and sometimes 1. What is happening? Did I mess up the GPIO?

Please help


1 Answer 1


hanging wire works as an antenna. it's absolutely correct to read random values from the port connected to the nothing, you should not worry about it much. when you use push button, you'd better use pull-ups or pull-downs to avoid input pin floating in the air:

enter image description here

  • 2
    The Raspberry Pi supports internal pull-up and pull-down resistors so the external pull-up you describe is not necessary if you use the internal pull-up.
    – Craig
    Aug 5, 2013 at 20:36
  • Just to add. The value of the pin will be high (1) if not pressed. Once the button is pressed it will read low (0). Slightly unintuitive.
    – Gerben
    Aug 6, 2013 at 16:03
  • 1
    @Gerben you may flip the schematics vertically to replace pull-up with a pull-down, if you like.
    – lenik
    Aug 6, 2013 at 23:36
  • But pull-ups are more energy efficient, I believe :-)
    – Gerben
    Aug 7, 2013 at 10:40

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.