Let's Make Robots!

Arduino As Alarm

I want to connect on my arduino (UNO) a 12v power source and an lcd . When the main power disconnect it will write on lcd Power Failure and switch to backup battery.And when the main power recconect it will say Power Live and switch to main poer


And My Question Is How I Can Connect the Main power  And LCD On arduino and print the info on the LCD


I would appreciate it a lot if you help me

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

12v is too much for an arduino. I would search google for "voltage regulator" and "buck regulator".

LCDs (and connections) are covered well at the Arduino website and Arduino playgroud.


Do some searching, then get back to us.

Ok, here's what you want to do...

Forget the LCD for now, it will just be an indicator of the power drop --You could blink a LED or buzz a buzzer instead --this part really does not matter. Let's focus on the battery level monitoring.

The ADC inputs measure voltage levels from say, 0-5v. To work, they need a "reference voltage", usually the working voltage of the chip itself. As your batteries die (say a 4 AA pack), the overall voltage drops but also the reference voltage for the ADC's. Everything drops together, the ADC values do not change.

Now, lets say you are using a 7.2v supply and a 5v regulator. As the voltage drops, the chip still receives 5v (steady 5v from the regulator) --the reference voltage for the ADC does not change now. If we were to watch your batteries now, we can see the voltage drop when we compare it to this steady 5v from the voltage regulator. The problem is that you can not send 7.2v into an ADC, you will fry the pin. --We use a voltage divider to drop this voltage down to something under 5v when the battery is full. An ideal situation is to use resistors on your voltage divider so it will put out 5v exactly when the battery is full.

Now what we have, is your 12v battery going to a volt reg and your voltage divider. The volt reg keeps the voltage reference point steady and your voltage divider keeps the battery voltage under 5v, but still in proportion of its total voltage.

You can now read the level of your battery via an ADC input.

when i create this forum i made a mistake but now i correct it plz take a look again and tell me what do you believe

OK, everything I said above still stands (about reading the battery level).

Now, it looks like the problem is disconnecting one supply and reconnecting another one. This is a new one on me, I'm afraid. At first glance, I would think you could use a DPDT relay to switch between the two, and a really huge capacitor to maintain power in the split second it would take the relay to click, but to be honest, I don't know.

If this were my project, I would look at UPS systems (uninterruptible power supply). I have no idea how they work, but this is what you are trying to replicate --I would start there.

i know how to switch it to backup supply but i want the code to read the adc value from voltage devider and print on lcd it status 

OK, it seems you want to monitor and external batttery. I read the ebay description for your breakout board and it seems it has a max input of 25v. This would put your 12v battery somewhere in the middle of the ADC range --it should work just fine.

You should connect your breakout board to your 12v battery, connect all your ground wires (just like you normally would) and take an ADC reading. That's it.

From there, you simply need to decide what ADC reading corresponds with a "dead" battery and use that for your threshold.

Sending text to the LCD is a pretty "standard" thing to do --The arduino website has all the info.