Introduction: Arduino Battery Tester (1.5v)

This project is intended to test the voltages of batteries that are 1.5 volt variety.

IE: AA, AAA, C, and D

Warning: If you try and test any batteries above 1.5 volts it may fry your Arduino. The same applies to testing more than one battery at a time. For example, if you test 4 x 1.5v batteries, that is above 5 volts and will fry your Arduino.

Step 1: Bill of Materials


3 x 330 ohm resistors

1 x Arduino Uno

3 x LED's (can be any color, I went with green, yellow, red)

1 x Breadboard

1 x Battery holder (AA, AAA, C, D)


You can just use the testing wires with no holder. Up to you.

Various jumper wires


Arduino IDE

Step 2: Assembling the Board

Start out with a clutter free and static free work station. Lay out all the components you'll be using in front of you.

Schematics can be found in two forms:

One is for the more visual learners and the other is a more traditional pinout.

Run a jumper from the Arduino's 5v pin to the positive side of the rail on your board.

Run a jumper from the GND pin to the negative side of rail.

Place the short leg of the first LED in E3 and the longer leg in E4

Place the short leg of the second LED in E7 and the longer leg in E8

Place the short leg of the third LED in E11 and the longer leg in E12

Bend resistors so the legs connect the GND rail to E3, E7, and E11

Run a jumper from E4 to pin 9 on the Arduino

Run a jumper from E8 to pin 10 on the Arduino

Run a jumper from E12 to pin 11 on the Arduino

Connect a relatively long wire to pin A0 on the Arduino. This will connect to the positive side of the battery we are testing.

Connect another wire of around the same length to either the ground rail or the spare GND pin on the Arduino.

When you're done it should look something like the schematics above.

Step 3: Time to Program!

The code that I used was an edited version of wcyoder's program, which is used to test more than one battery. His instructable can be found here:

The code follows:

//Simple battery testing program
#define newLED 11 //Set the new led to pin 11

#define okLED 10 //Set the okay led to pin 10

#define oldLED 9 //Set the old/dead led to pin 9

int analogValue = 0; //value of the voltage, raw format

float voltage = 0; //voltage in edited format

int ledDelay = 2000; //delay in writing

void setup() {

pinMode(newLED, OUTPUT); //Set all 3 LED's to output mode

pinMode(okLED, OUTPUT);

pinMode(oldLED, OUTPUT);


void loop() {

analogValue = analogRead(0); //Read the voltage off of pin A0


if (voltage >= 1.52) { //if the voltage is above 1.52

digitalWrite(newLED, HIGH); //Illuminate green LED


digitalWrite(newLED, LOW);

} else if (voltage < 1.52 && voltage > 1.48) { //If the voltage is between 1.48 and 1.52

digitalWrite(okLED, HIGH); //Illuminate yellow LED


digitalWrite(okLED, LOW);

} else if ( voltage <= 1.5) { //If voltage is less than 1.48

digitalWrite(oldLED, HIGH); //Illuminate red LED


digitalWrite(oldLED, LOW);



float voltage(int analogValue){

voltage = 0.0048 * analogValue; return voltage;


When you're done copy/pasting or rewriting go ahead and send it to the Arduino.

Step 4: Using the Tester

Supply power to the Arduino via the USB connection to your computer or a 9v adapter into the power jack.

Take the wire running from A0 and connect it to the positive post of your battery and take a wire running to GND and connect it to the negative point on your battery.

If the green LED lights up, the battery is good to go!

If the yellow LED lights up, the battery is on its last leg of its journey in powering your electronics.

If the red LED lights up, its time to say goodbye to the battery and part ways.

Step 5: Thanks!

That's it. If you made this project be sure to hit the "I made it" button.

If you enjoyed it please favorite it and pass it around.

If you have any suggestions/corrections to submit please comment them and I'll consider them.

Thanks for reading, and I hope you'll read some of my future instructables!