# Battery Tester LED Display

250

2

1

Test battery voltage indicated by three LEDs; Green, high; Yellow, medium; Red, low.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Build Circuit

What you will need:

- Arduino UNO

- 3 LEDs, preferably red, yellow, and green. (I used an RGB LED since I didn't have a green LED)

- 4 330k ohm resistors

- 8 jumper wires

- 2 alligator clamps

- C Battery for testing

## Step 2: Write Code to Read Battery Voltage

int sensorValue;

float voltage;

void setup() {

Serial.begin(9600);

pinMode(0, INPUT);

}

void loop(){

voltage = sensorValue * (5.00 / 1023.00); //convert the sensor read to a true voltage.

Serial.println(voltage);

## Step 3: Write Code to Write Voltage to LEDs

int sensorValue;

float voltage;

void setup() {

Serial.begin(9600);

pinMode(0, INPUT);

pinMode(11, OUTPUT);

pinMode(12, OUTPUT);

pinMode(13, OUTPUT);

}

void loop(){

voltage = sensorValue * (5.00 / 1023.00); //convert the sensor read to a true voltage.

Serial.println(voltage);

LEDs();

}

void LEDs(){

if (voltage > .53) {

digitalWrite(11, HIGH); }

else if (voltage <.53) {

digitalWrite(13, LOW);

digitalWrite(12, LOW);

digitalWrite(11, LOW); }

if (voltage > 1.06) {

digitalWrite(13, LOW);

digitalWrite(12, HIGH);

digitalWrite(11, LOW); }

else if (voltage <1.06) {

digitalWrite(12, LOW); }

if (voltage > 1.59) {

digitalWrite(13, HIGH);

digitalWrite(12, LOW);

digitalWrite(11, LOW); }

else if (voltage <1.59) {

digitalWrite(13, LOW); }

}

## Recommendations

• ### Internet of Things Class

22,837 Enrolled

## Discussions

Thanks for sharing :)