Battery monitor

D396

Senior Member
Here is a battery monitor, it lights a led up on pins 0,1,2,3 when the battery is full:
Pins 0,1,2 when the battery is ¾ full
Pins 0,1 when the battery is ½ full
Pin 0 when the battery is ¼ full
No leds on when empty.
It uses a voltage divider so the picaxe will not get destroyed.
Here is the code for it (only use it for a 9V battery):

Code:
symbol batt =1
symbol full = 255
symbol THREEFOURTHS = 191
symbol ONEHALF = 126
symbol onefourth = 63
symbol empty = 35
symbol reading = b0

' ONLY USE ON 9V BATTERY GREATER VOLTAGE CAN CAUSE DAMAGE TO THE PICAXE ADC




main:
readadc batt,reading
if reading <= full and reading => Threefourths then
high 0,1,2,3
else if reading <= THREEFOURTHS and reading => ONEHALF then
low 3
high 0,1,2
else if reading <= ONEHALF and reading => ONEFOURTH then
low 2,3
high 0,1
else if reading <= ONEFOURTH and reading => EMPTY then
low 1,2,3
high 0
else if reading <= EMPTY and reading > 0 then
low 0,1,2,3
endif
goto main
 

Attachments

fernando_g

Senior Member
Thanks for sharing.
By using a different value resistor divider, voltages higher than 9 volts may also be accomodated.
 

Scott Thomas

New Member
Resistor Values?

Could someone please supply the resistor values to allow this circuit to work with a 12v car battery.

Scott
 
Top