Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Battery Voltage Level Indicator with Alert Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Battery Voltage Level Indicator with Alert Buzzer

Circuit Documentation

Summary

This circuit is designed to monitor the voltage level of a 12V battery and visually indicate the charge level through a series of LEDs. It uses an Arduino UNO as the central microcontroller to read the battery voltage and control the LEDs and a buzzer. The LEDs represent different charge levels, and the buzzer is used as an audible warning when the battery charge is critically low. The circuit includes a voltage divider to step down the battery voltage to a level that can be read by the Arduino's analog input.

Component List

Wiring Details

Arduino UNO

LEDs

Resistors

Buzzer

12V 200Ah Battery

Documented Code

const int ledPins[] = {2, 3, 4, 5, 6}; // Array of LED pins
const int buzzerPin = 7; // Buzzer pin
const int batteryPin = A0; // Battery voltage measurement pin

void setup() {
  for (int i = 0; i < 5; i++) {
    pinMode(ledPins[i], OUTPUT); // Set LED pins as outputs
  }
  pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
  Serial.begin(9600); // Start serial communication
}

void loop() {
  int batteryLevel = analogRead(batteryPin); // Read battery voltage
  float voltage = batteryLevel * (5.0 / 1023.0) * (24.0 / 5.0); // Convert to actual voltage
  int percentage = (voltage / 24.0) * 100; // Calculate battery percentage

  // Print battery voltage and percentage to serial monitor
  Serial.print("Battery Voltage: ");
  Serial.print(voltage);
  Serial.print("V, Percentage: ");
  Serial.print(percentage);
  Serial.println("%");

  // Turn on LEDs based on battery percentage
  for (int i = 0; i < 5; i++) {
    if (percentage >= (i + 1) * 20) {
      digitalWrite(ledPins[i], HIGH);
    } else {
      digitalWrite(ledPins[i], LOW);
    }
  }

  // Activate buzzer if battery percentage is 30% or less
  if (percentage <= 30) {
    for (int i = 0; i < 3; i++) {
      digitalWrite(buzzerPin, HIGH);
      delay(500);
      digitalWrite(buzzerPin, LOW);
      delay(500);
    }
  }

  delay(1000); // Update every second
}

This code is designed to run on the Arduino UNO. It initializes the pins connected to the LEDs and the buzzer, reads the battery voltage through a voltage divider, calculates the battery percentage, and then updates the LEDs and buzzer accordingly. The serial monitor outputs the battery voltage and percentage for monitoring purposes.