Electrical – Control color of Bi-Color LED using Arduino

arduinoledmosfetpower

I have this push-button switch which has two solder lugs for 12 VDC power and will illuminate red or green depending on the polarity of the wiring. It may not actually use a bi-color LED, but it seems to be a good representation for how it works. I can't find a schematic for the switch, though I expect it may be something like this:
enter image description here

I'm providing the 12V using an LM7812C voltage regulator but I'm struggling to figure out how I could control the polarity of the applied voltage using an Arduino. My idea is to have an Arduino control a MOSFET to switch power to the LED, though I get lost trying to find a way to flip polarity.

Is there a way I could control the LED to be red, green, or off using outputs from the Arduino?

Or alternatively, just have the switch default to one color and switch to the other when triggered by an output from the Arduino?

Thank you!

Best Answer

You could also do it with minimal components with a suitable dual op-amp configured as two comparators driven by two outputs from the micro.

High on one low on the other would turn on a particular color. Both high or both low would turn it off entirely.

schematic

simulate this circuit – Schematic created using CircuitLab

NOTE: R1 here is assumed to be built into the switch so your LEDs don't fry at 12V. But you need to verify what that illumination method really is.

ALTERNATIVE APPROACH: You can also hook the amps up as simple amplifiers with enough gain to drive the outputs to the rails like below. It requires four more resistors but gets rid of some issues with driving op-amps as comparators.

schematic

simulate this circuit

Related Topic