Introduction: Battery Tester
This Arduino project will help you test your battery. You will get an estimate of the amount of battery your battery has. DO NOT EXCEED 5V
MATERIALS:
- 10 wires
- 3 LED lights(color doesn't matter)
- 1 bread board
- 1 Arduino board
- 1 battery(5V or less)
Step 1: Code
float on = 1.4;
float off = 1,4;
float Volts;
void setup(){
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
Serial.begin(9600);
}
void loop(){
Volts = analogRead(0);
if(convert(Volts) > on){
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
}
if(convert(Volts) > off){
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
}else
if(convert(Volts) < off){
digitalWrite(13,HIGH);
}
Serial.println(convert(Volts));
}
float convert(float watts){
return((watts/1024)*5);
}
Step 2: Assembly
Different types of batteries can be used. Just a few tweaks of the code are needed. Do not use a battery that is higher than 5V.