Test Battery Life With Arduino Mega 2560

Introduction

  • In this article I have explained about testing the Life of Battery in Arduino Mega 2560.
  • It can be used in TV remotes and Flash lights and can also be used to check the power of battery.
Parts Of Lists
  • Arduino Mega 2560
  • Battery  
  • LEDs
  • Hookup Wires 
Connections
 
Step 1: Connection of Battery to Arduino Board
  • Connect the Battery positive pin to the Analog pin of 03 to the board.
  • Connect the negative pin to the GND to the board. 
Step 2 : Connections Of LEDs to Arduino Board
 
LED 1 
  • Connect the positive pin to the 13 of the board.
  • Connect the negative pin to the Gnd  
LED 2
  • Connect the positive pin to the 12 of the board.
  • Connect the negative pin to the Gnd 
LED 3
  • Connect the positive pin to the 11 of the board.
  • Connect the negative pin to the Gnd 
Programming
  1. int led1 13;  
  2. int led2 12;  
  3. int led3 11;  
  4. int analogValue = 0;  
  5. float voltage = 0;  
  6. int ledDelay = 2000;  
  7.   
  8. void setup()   
  9. {  
  10.     pinMode(led1, OUTPUT);  
  11.     pinMode(led2, OUTPUT);  
  12.     pinMode(led3, OUTPUT);  
  13. }  
  14. void loop()   
  15. {  
  16.     analogvalue = analogRead(0);  
  17.     voltage = 0.0048 * analogvalue;  
  18.     if (voltage >= 1.6)  
  19.     {  
  20.         digitalWrite(led1, HIGH);  
  21.         delay(ledDelay);  
  22.         digitalWrite(led1, LOW);  
  23.     }   
  24.     else if (voltage < 1.6 && voltage > 1.4)   
  25.     {  
  26.         digitalWrite(led2, HIGH);  
  27.         delay(ledDelay);  
  28.         digitalWrite(led2, LOW);  
  29.     }   
  30.     else if (voltage < = 1.4)   
  31.     {  
  32.         digitalWrite(led3, HIGH);  
  33.         delay(ledDelay);  
  34.         digitalWrite(led3, LOW);  
  35.     }  

    Explanation:
    • In this article, I have explained about testing the Life Of Battery in Arduino Mega 2560.
    • When the voltage is <1.6 volt, it can have the power
    • When the voltage is <=1.4 volt, it cannot have the power.