1
\$\begingroup\$

Please note: Although this question involves a Raspberry Pi, I believe it an electronics/wiring question at its heart.


I'm new to electricity & electronics and I'm trying to get this simple on-off-on-off switch to work as a pushbutton to my Raspberry Pi 1 Model A.

By default, this switch works as follows:

  1. You press the switch, its "closed" and is considered on, but is routing power through the left pin
  2. You press it again and that makes it open/off
  3. You press it again and that makes it closed/on, but now its routing power to the right pin
  4. You press it again and its off; if you press it again we rinse and repeat this cycle

However I would like to wire the left/right pins together to effectively transform this into a typical on/off switch whereby the behavior is:

  1. You press the button and its closed/on, routing power to the line joining the left and right pins together
  2. You press it again and its open/off; if you press it again we rinse and repeat this cycle

I believe the wiring diagram for this type of setup is:

enter image description here

So to begin with, if that wiring diagram is incorrect, please begin by correcting me!

Assuming its correct, then this is my best attempt to wire it to my pi:

enter image description here

So:

  • Attach left & right pins on the pushbutton together and then route them to the GPIO input pin
  • Route the middle pin on the pushbutton the GND on the RPi

Can anyone take a look at this and help nudge me along? Have I joined the left & right pins correctly? Do I need a resistor anywhere (if so how strong and where does it need to go)? Am I wiring the joined left/right pins to the pi correctly? Am I wiring the switch to power & ground correctly? Thanks for any-and-all help!

\$\endgroup\$
1
\$\begingroup\$

Yes, that's exactly right, assuming you accurately described the switch. Simply tie the left and right pins together, no resistor needed.

Don't forget the pull up resistor in your schematic. From 3.3V to 10K ohm resistor to the gpio pin.

\$\endgroup\$
  • \$\begingroup\$ Thanks @Passerby (+1) - just to confirm what you're saying: where do I need to place the resistor? \$\endgroup\$ – smeeb Sep 16 '17 at 2:23
  • \$\begingroup\$ Also, I'm curious as to why the resistor is so big (10k Ohms). Any ideas there? \$\endgroup\$ – smeeb Sep 16 '17 at 2:24
  • 1
    \$\begingroup\$ 10k is a high resistance, meaning low current. It's a weak pull up. The lower the resistance the more current is pulled, which normally means wasted power and possible damage to a rpi. And you place it where your first image shows. Between 3.3V to the gpio. \$\endgroup\$ – Passerby Sep 16 '17 at 2:27
  • \$\begingroup\$ Thanks for the explanation on the ohms there @Passerby (+1 again). Sorry, I'm just not 100% understanding you on where to place the resistor though...please see my updated question above. I drew two possible locations for a "R1" resistor...is either of them correct? Thanks again! \$\endgroup\$ – smeeb Sep 16 '17 at 2:35
  • \$\begingroup\$ I think I'm getting confused because you're saying "3.3V to the gpio", however if you look at my drawings, I don't have the 3.3V voltage source wired to anything. \$\endgroup\$ – smeeb Sep 16 '17 at 2:37

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.