0
\$\begingroup\$

Please note: Although my question involves a Raspberry Pi, this is a pure electronics question at heart.


I'm trying to figure out how I can wire this illuminated momentary switch to my Raspberry Pi 1 Model A (hereafter RPi) such that:

  • The switch is normally open
  • When pushed down: it closes the circuit, lights up and fires a HIGH signal to a GPIO input pin (GPIO 04 in my case)
  • If needed, I can make the GPIO 07 pin an output pin and make it available to help run the light/LED inside the switch, but not sure if that's needed

I will be setting the RPi's internal resistor on this pin, so I don't think I need a resistor for the switch, but I believe I still need one for the switch's LED/light (please confirm!). I will also be working out a "debouncing algorithm" at the software layer if needed.

But I'm stuck trying to figure out how to wire the dang thing to my RPi:

enter image description here

According to page 15 of that switch's datasheet:

enter image description here

So I'm not sure:

  • What GPIO 04 on the RPi is supposed to connect to on the switch; and
  • What I'm supposed to do with Pins 1 and 2 on the switch; and
  • What I'm supposed to do with Pins X1 and X2 on the switch; and
  • What I'm supposed to wire GPIO 07 up to (if anything)

Can anyone nudge me in the right direction here?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

From page 16:

• A current-limiting resistor is built into the LED Lamp, so external resistance is not required.

You have the A22NZ-BNM-TWA model, so 6VDC is needed.

enter image description here

I'm assuming that since you are using this button you have 6VDC available. Since you can't drive 6VDC and any significant current with the RPis GPIO, you could do the following:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
9
  • \$\begingroup\$ Thanks @Wesley Lee (+1) - a few followup questions if you don't mind: (1) I plan on using the RPi's internal GPIO pin resistor, so does that mean I can omit the 10k-ohm Pull Down resistor in your schematic? (2) In that case, would I also still need the R1 100ohm resistor, if so, just curious as to why? (3) What function is the Bleeder Resistor performing and what switch pins (1, 2, 3, 4, X1, X2, etc.) is it wired to? And finally (4) where are the switch's Pin 1 and Pin 2in your schematic? Thanks again so very much!!! \$\endgroup\$
    – smeeb
    Oct 4, 2017 at 1:59
  • 1
    \$\begingroup\$ @smeeb 1) that pull down is for the FET, to keep it off unless something drives it HIGH, you don't necessarily have to wire the Switch to the same GPIO, so I included the resistor, its good practice 2) the R1 resistor is a gate resistor for the FET, to prevent current inrush when charging the FETs parasitic capacitor. 3)The bleeder resistor is recommended by the datasheet to prevent false lighting in case of some stray current, see page 16. Its in parallel with the LED. \$\endgroup\$
    – Wesley Lee
    Oct 4, 2017 at 2:06
  • 1
    \$\begingroup\$ 4) I'm not sure if the button has 2 leds in antiparallel so I don't know the polarity of the internal LED, but I added some notes about X1/X2 on schematic. \$\endgroup\$
    – Wesley Lee
    Oct 4, 2017 at 2:06
  • 1
    \$\begingroup\$ I'm not sure if the RPis internal resistor can be used as pull down. If yes, then you can probably connect the FET to the same GPIO (if only as pull up then the logic will be inverted). In any case you can use a separate GPIO if needed to control the LED. \$\endgroup\$
    – Wesley Lee
    Oct 4, 2017 at 2:08
  • 1
    \$\begingroup\$ Thats a battery charger, it wont work as a regular power supply. What are you powering the RPi with? You can use a small boost converter to convert 5V to 6V, or use a buck converter or linear regulator do convert a higher voltage to 6V. (You could even try powering it with 5V and see if its enough) \$\endgroup\$
    – Wesley Lee
    Oct 9, 2017 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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