Can someone help me!!! Write a code for charging a battery?

Hi, I needed help writing a code where once a battery is low on energy, a red LED light will blink to indicate low on battery. Please help!

The community is here to assist you, not to do the work for you. Please elaborate on your question and tell us what you have tried, what you have, any setup you have tried, and post any code you have.

I am also sure there are plenty of tutorials and sample code out there, so give the old google a go first.

We also need to know what sort of battery and how it is connected to the Arduino.

And is it the battery that is powering the Arduino?

...R

If it's the battery that is powering the Arduino and is not going through the voltage regulator, you can look at something like this:

There is a link there to the secret Arduino voltmeter. It's not a secret, it is possible by using its own internal reference to measure the VCC. That is the VCC of the ATmega328P chip itself. I have that in a project with a ATmega328P, ATmega8, and a Arduino Mega 2560 board.

Grab a readVcc() or secret voltmeter from somewhere, test it, and show a full test sketch to us, so we can try it as well.
It can be hard to return to normal when using analogRead() after the internal mux has been used to measure VCC. I use a few analogRead() and delays to get back to normal. I'm still having troubles to make the ATmega2560 go back to normal.

If you have a battery powered barebones Arduino with a RF transmitter, it is very handy to transmit the battery voltage once per hour or so. That way you can also track how low the battery can go until it stops working.

The technique is explained in this Thread. Look at Reply #8.

...R

Hi, I needed help writing a code were if a battery drops down to a certain voltage a LED light would blink to indicate charging is required. Please help!

Thanks

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator