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):
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
-
103.1 KB Views: 467