## Introduction: Linkit One Battery Tester

A few months ago I created an instructable in which I should how to create a battery tester using the Linkit One board, in this instuctable I'm going to show you how to make a battery tester using the Linit one. A battery tester works by checking the voltage of 1.5V cells or even 3V button cells and tells you how much of the charge is left. Like red indicates that the battery is dead and white indicates that the battery is full.

## Step 1: Tools and Components

All the components you require for this instructable are -

• Different colored LEDs
• Jumper wires
• 2.2k resistor

## Step 2: Circuit

Follow the circuit above it is quite simple and can be easily assembled on a breadboard. Also add a suitable resistor for the LEDs (I did not do that because I'm using 5V tolerant LEDs). For the colors of the LED I used

• Red to indicate that the battery is Low
• Green to indicate that the battery is running
• White to indicate that the battery is Full

## Step 3: Code

Copy the below code and paste the below code in the Arduino IDE and then select a suitable COM port and upload the code to the Linkit One. If you are going to measure a 3V button cell then you need to edit the code to read for a voltage value of 3v.

```#define newLED 2 // green LED 'new'#define okLED 4 // green LED 'ok'
#define oldLED 6 // red LED 'old'
int analogValue = 0;
u float voltage = 0;
int ledDelay = 2000;
void setup()
{
pinMode(newLED, OUTPUT);
pinMode(okLED, OUTPUT);
pinMode(oldLED, OUTPUT);
}
void loop()
{
w voltage = 0.0048*analogValue;
x 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);
}```

## Step 4: Finishing

After uploading the code power on the Linkit One and you should see the red LED light up, and connect a battery accross the ground terminal and the analog pin 0, and you should see the LED light with respect to the voltage of the battery. This project can be used to check the voltage off the cells used by toys as some times there is still a lot of charge left in it.