Introduction: Simple Arduino Battery Tester
The Arduino battery tester is a tool by which you can check how charged a battery is.
Step 1: Hardware Components
Arduino Uno
Breadboard
LED'S( Red, Yellow, Green)
5.1k Zener Diode
Resistor 100 ohm
Resistor 2.2k ohm
Breadboard Connecting wires.
Step 2: Set Up
The Zener diode is used to test batteries that have a voltage greater than 8v.
The 2.2k ohm resistor minimizes the current coming from the battery to something that the Arduino will be able to take in. High current may damage Arduino.
The circuit system also has three various LEDs, each of these LEDs shows how much charge there is left in the battery.
Red will show the battery is low/almost dead. Yellow will present the battery being roughly half used up. The green will shows the battery is full. We connect a 100-ohm resistor to each LED individually from the ground pin to the ground connection.
Circuit connection steps are mentioned below:
1. Wire the ground pin on the Arduino to the ground rail on the breadboard.
2. Put the three LED's respectively on a breadboard and connect ground pins to the ground rail.
3. Locate a 100-ohm resistor onto the positive end of the LEDs then connect a wire from a resistor to the relevant pins on the Arduino.
The LEDs should connect to the relevant pin numbers as mentioned below:
Red LED = 4
Yellow LED = 3
Green LED = 24.
Now connect from analog pin 0 (A0) to the breadboard. After this add a 2.2k resistor and the Zener diode. Connect a wire from other ends of the diode to the ground rail. After setting all the connection and code, your project is ready for the testing. IoT Training Online is the way to implement your ideas and skills on various applications and projects.
Step 3: Circuit Schematic
Step 4: Run a Code
int green Led = 2;
int yellow Led = 3;
int red Led = 4;
int analogValue = 0; // analogValue variable is where we will be storing the value that comes from the analog input//
float voltage = 0;
int ledDelay = 1000; //ledDelay is how long you want the LEDs to remain on before switching off//
//set up all our LED pins as outputs//
void setup()
{
pinMode(greenLed, OUTPUT);
pinMode(yellowLed,OUTPUT);
pinMode(redLed,OUTPUT); }
// Read the analog pin //
void loop()
{
analogValue = analogRead(A0);
voltage = 0.0048*analogValue;
//Compare calculated voltage with defined voltage values//
if( voltage >= 1.6 )
digitalWrite(greenLed, HIGH);
else if (voltage > 1.2 && voltage < 1.6)
digitalWrite(yellowLed, HIGH);
else if( voltage <= 1.2)
digitalWrite(redLed, HIGH);
delay(ledDelay);
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(greenLed, LOW);
}