Having found some old Ni-mh batteries, I want to buy a La Crosse Technology BC-700 Alpha Power Battery Charger to do the discharge test to find out their working capacity, but the charger costs about $35, and I don't really need it, so I decided to make my own dis-charger using my Arduino uno. Here is the result, I hope anyone with knowledge about this in term of electrical circuitry and software programming can correct me if there is anything wrong. Thank you in advance
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
int leds[8]={0,1,2,3,4,5,6,7};
int Vohm[2]={A0,A1};
int Button[4]={A2,A3,A4,A5};
int sec=0;
int minu=0;
int hr=0;
unsigned long time=0;
unsigned long pstimer=0;
float DV=0;
float BV=0;
int ma=0;
float mah=0;
float mahnow=0;
//========================================================================================================================
void setup() {Â
lcd.begin(16,2);
for (int x=0; x<8; x++){
pinMode (x, INPUT);
}
pinMode (A2, INPUT); // battery voltage
pinMode (A5, INPUT);// resistor drop voltage
}
//========================================================================================================================
void loop() {
Â
unsigned long timer= millis();
if(timer-pstimer > 1000){
 sec++;
Â
 float BV1 = analogRead(A2);
 BV = BV1/1023*5.18;Â
 float DV1 = analogRead(A5);
 DV = DV1/1023*4.96; Â
Â
 ma=DV*1000;
Â
 mahnow=DV/3.6;
 mah=mah+mahnow;
Â
 lcd.setCursor(10,1);
 lcd.print("  ");
 pstimer = timer;
}Â
if(sec==60){
sec=0;
minu++;
}
if(minu==60){
minu=0;
hr++;
}
Â
char szTime[7];
sprintf( szTime, "%02d:%02d", hr, minu );
lcd.setCursor(0,0);
lcd.print( szTime );
if (BV>0.5){
lcd.setCursor(6,0);
lcd.print(mah);}
lcd.setCursor(13,0);
lcd.print("Mah");
lcd.setCursor(0,1);
lcd.print(BV);
lcd.setCursor(5,1);
lcd.print(DV);
lcd.setCursor(10,1);
lcd.print(ma);
lcd.setCursor(14,1);
lcd.print("Ma");
if (BV>1.2){
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(6,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}
if (BV>0.9){
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}
if (BV>0.5){
digitalWrite(2,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}
}