hIOTron
Created August 9, 2019

Arduino Battery Tester

The Arduino battery tester is a tool by which you can check how charged a battery is.

Arduino Battery Tester

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
Breadboard (generic)
Breadboard (generic)
×1
Bredboard wires
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Resistor 2.21k ohm
Resistor 2.21k ohm
×1
5.1K Zener diode
×1

Story

Read more

Schematics

Circuit Schematic

Code

Run a program

Arduino
int greenLed = 2;
int yellowLed = 3;
int redLed = 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);
}

Credits

hIOTron

hIOTron

78 projects • 2 followers
hIOTron is an internet of things based company that offers an IoT Platform, products, IoT Solutions, and IoT Training.

Comments