i want to ON-OFF two lights(white and red), one from main power source(white light) and one from ups(battery). When main power is present, white light should be ON and red should be off. And when main power fails, red should be ON and White should be OFF. I have Arduino, usb cable, external power supplier(adapter of 12V).

Can any one please suggest me how do i proceed for this ??


If your battery voltage is lower than 12 but sufficiently high to power the arduino (let's say 9V), you could put a white LED on the 12V line and a red LED on the battery line, like this:

         WHITE       RED         
 |             |                |
_|_          Arduino           _|_
 - 12V         |                -   Battery

This should work, as long as the LEDs can withstand the reverse voltage. And you do not need to drive them from the Arduino. If you still want to know the status fro mthe Arduino (mains or battery) you can sample the voltage level across the Arduino.

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.