Arduino Battery Tester




Introduction: Arduino Battery Tester

My name is Will Yoder and I am a senior at NC State. This is my final project for TDE 359, which is electronics at North Carolina State University. For this project we were suppose to take an existing Arduino project and modify it to create our own project. In this project, I took a single cell battery tester and manipulated it so that the Arduino can take batteries that have greater than 8 volts. I did this by adding a zener diode right after the battery that is being tested. This will make sure the Arduino does not get fried from the voltage being to high.

A problem that I had with this project was my laptop was not able to recognize the Arduino Uno. The code was written and did not have any problems, but when I tried to upload it onto the micro-controller my computer would come back saying it did not have the correct programmer.

I have never used a micro-controller before. This project was a good way for me to learn some basic coding with Arduino and realize all the endless possibilities of the projects for with Ardiunos. At first I wanted to do the flame throwing pumpkin with the Arduino. I realized that would be out of my knowledge range for this project as well as my budget. With this project I was able to get experience with the coding and learned some of the coding.

Step 1: The Hardware Required to Build the Battery Tester

In order to make a battery tester, you will need the following items:

-Three 560 ohm resistors (Green, Blue, Brown)

-One 2.2k ohm resistor (Red, Red, Red)

-One green LED

-One yellow LED

-One red LED

-One zener diode

-a breadboard-various jumpers (connecting wires)

-One Arduino Uno R3 Microcontroller with usb cable

Step 2: The Block Diagram

In the block diagram, the Arduino Uno will be powered by the USB drive that is connected to the computer. The battery that is being tested will then provide voltage from battery to the Arduino. Then the Arduino will use the code that has been downloaded onto the micro-controller and decipher which light it should light up based upon the voltage. The Arduino will then light up the correct light to tell the user how much life is left on the battery that is being tested.

Step 3: The Schematic

Attached is an electrical schematic drawn up for the project, courtesy of John Boxall at the Arduino Workshop with my addition of the zener diode before the 2.2k resistor. The arduino will supply the power from the USB port, while the voltage coming from the batteries that are being tested will decide which light will light up.

Step 4: The Code

Here is the code in order to run the battery tester with the Arduino Uno. This code is courtesy of John Boxall at the Arduino Workshop.

Be the First to Share


    • Anything Goes Contest

      Anything Goes Contest
    • Puzzles Challenge

      Puzzles Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest



    4 years ago

    This code isn't working in my arduino program it says theres an unexpected id or something I am not advanced in programming so if anyone can help ASAP it would be great... :) Thank you.


    6 years ago

    #define newLED 2 // green LED 'new'

    #define okLED 4 // yellow LED 'ok'

    #define oldLED 6 // red LED 'old'

    int analogValue = 0;

    float voltage = 0;

    int ledDelay = 2000;

    void setup(){

    pinMode(newLED, OUTPUT);

    pinMode(okLED, OUTPUT);

    pinMode(oldLED, OUTPUT);


    void loop(){

    analogValue = analogRead(0);

    voltage = 0.0048*analogValue;

    if(voltage >= 1.6){

    digitalWrite(newLED, HIGH);


    digitalWrite(newLED, LOW);

    } else if(voltage <1.6 && voltage > 1.4){

    digitalWrite(okLED, HIGH);


    digitalWrite(okLED, LOW);

    } else if(voltage <= 1.4){

    digitalWrite(oldLED, HIGH);


    digitalWrite(oldLED, LOW);



    wow great but this explanation lakes some explanations :D

    took me some time but still nice one