I'm trying to use a switch to to provide input to software running on the Raspberry Pi. I have software running right now that continually reads the input pin and prints the result. Problem is, even when nothing is connected to it, the voltage reading from the input pin to circuit ground reads about 0.9V. The software rapidly flickers between TRUE and FALSE.

Is this a software issue? If not, how can I avoid this?

Thanks for any advice, - Chase


The input in question is "floating" until the button is pressed, due to its inputs being of very high impedance.

You need to add a pull-down resistor to the pushbutton, 10k is commonly used, thus:

Pull-down resistor for switch

That way, the Raspberry Pi input sees a false (0 Volts) until the button is pressed, then a true until released.

  • \$\begingroup\$ RaspberryPi GPIO's are rated for 3.3V. This QnA clarifies this matter and has relevant links. \$\endgroup\$ – icarus74 Jan 6 '13 at 14:42
  • \$\begingroup\$ @icarus74 I'm sorry, I don't get your point: 3.3V or 5V, the rationale, and the answer, remain valid. \$\endgroup\$ – Anindo Ghosh Jan 6 '13 at 15:42
  • \$\begingroup\$ Answer, from rationale point of view, is perfect, it is the schematic which is misleading. For someone, who is new to electronics (and RaspberryPi) might take a highly rated answer as-is, and try to implement it, potentially leading to magic smoke being let out. The pitfall is 5V, since the pins are not 5V tolerant. \$\endgroup\$ – icarus74 Jan 6 '13 at 17:21
  • \$\begingroup\$ @icarus74 Hmm... If that deserves a downvote, I'll take care of it. \$\endgroup\$ – Anindo Ghosh Jan 6 '13 at 17:22
  • \$\begingroup\$ @icarus74 ... and done. \$\endgroup\$ – Anindo Ghosh Jan 6 '13 at 17:28

Your Answer

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

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