Wednesday 24 January 2018

Battery Tester using LEDs

What purpose does this instrument serve?
It is used to indicate the juice left in the battery. It helps us to distinguish between the new and the old batteries. This instrument could be of great use in households to check the life of the battery. Using this simple device, many new batteries lives can be saved. Also an electronic component requires a perfectly functioning battery for it to reach its optimum potential.
Why did we make this measuring device?
Perhaps, this is one of the easiest experiments using an Arduino board and we gladly accepted all the help google could give us. Beginners having Basic knowledge of Arduino board and bread board connections could succeed in completing this experiment.
Also the cost of making this instrument is quite low.
Materials required:
3 LEDs: Red, yellow and green
3 Resistors -560 ohm
1 resistor- 2.2 k ohm
AA battery
Bread board
Arduino Board 
Connecting wire
USB cable 
THE ALGORITHM
  1. Read from analog pin zero.
  2. Multiply the reading by 0.0048 to create a voltage value.
  3. If the voltage is greater than or equal to 1.6 V, then briefly turn on a green LED.
  4. If the voltage is greater than 1.4 V and less than 1.6 V, then briefly turn on a yellow
  5. If the voltage is less than 1.4 V, then briefly turn on a red LED.
  6. Repeat indefinitely.

Code:

#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); 
     delay(ledDelay);  
     digitalWrite(newLED, LOW);  
}  
     else if (voltage < 1.6 && voltage > 1.4 )  
   { 
       digitalWrite(okLED, HIGH);
       delay(ledDelay);    
       digitalWrite(okLED, LOW); 
   } 
     else if ( voltage <= 1.4 )
   {   digitalWrite(oldLED, HIGH); 
       delay(ledDelay);   
       digitalWrite(oldLED, LOW); 
   }
}

How does this device work?
We will measure the voltage and express the condition of the battery visually with LEDs. We’ll use the reading from analogRead () and then convert the reading to volts. The maximum voltage that can be read is 5 V, so we divide 5 by 1,024 (total no of possibilities), which equals 0.0048. For example, if analogRead () returns 512, then we multiply that reading by 0.0048, which equals 2.4576 V.

When a battery is connected to the circuit, one of the three LEDs might glow-
Red- The battery is connected is old and could die any second.
Yellow- The battery connected has completed almost half of its life.
Green- The battery connected is a new one.

No comments:

Post a Comment

SMART BLIND STICK The smart blind stick is the project made to help the blind people who is suffering when walking.It just uses to de...