Battery Tester LED Display

163

2

1

Posted in TechnologyArduino

Introduction: Battery Tester LED Display

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

Step 1: Build Circuit

What you will need:

- Arduino UNO

- Breadboard

- 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(){

sensorValue = analogRead(0);

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(){

sensorValue = analogRead(0);

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); }

}

Step 4: Test Different Batteries and Verify LEDs With Debug Window

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Space Challenge

      Space Challenge
    • Science of Cooking

      Science of Cooking
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    Thanks for sharing :)