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

Arduino Uno-Based Water Level Monitoring System with LED Indicators and Buzzer Alert

View and Edit Project In Cirkit DesignerImage of Arduino Uno-Based Water Level Monitoring System with LED Indicators and Buzzer Alert

Circuit Documentation

Summary

This circuit is designed to monitor water levels using a water level sensor and provide visual and auditory feedback through LEDs and a buzzer. The system is controlled by an Arduino Uno R3 microcontroller, which reads the sensor data and activates the LEDs and buzzer based on predefined thresholds.

Component List

  1. Arduino Uno R3

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: D8, D9, D10, D11, D12, D13, GND, AREF, SDA, SCL, D0/RX, D1/Tx, D2, D3, D4, D5, 6, D7, A5/SCL, A4/SDA, A3, A2, A1, A0, Vin, 5V, 3.3V, RESET, IOREF, NONE, USB Jack, Power Jack
  2. Water Level Sensor

    • Description: A sensor used to measure the water level.
    • Pins: SIG, VCC, GND
  3. LED: Two Pin (red)

    • Description: A red LED with two pins.
    • Pins: cathode, anode
  4. LED: Two Pin (yellow)

    • Description: A yellow LED with two pins.
    • Pins: cathode, anode
  5. LED: Two Pin (green)

    • Description: A green LED with two pins.
    • Pins: cathode, anode
  6. Buzzer

    • Description: A buzzer used for auditory feedback.
    • Pins: +, GND

Wiring Details

Arduino Uno R3

Water Level Sensor

LED: Two Pin (red)

LED: Two Pin (yellow)

LED: Two Pin (green)

Buzzer

Code Documentation

Arduino Code

const int analogInPin = A0;
int sensorValue = 0;

// Buzzer pin
const int buzzerPin = 2;

// Timing variables
unsigned long previousMillis = 0;
const long interval = 500; // Interval for toggling the buzzer (in milliseconds)
bool buzzerState = LOW; // Current state of the buzzer

void setup() {
  // Declare pin to be an output:
  pinMode(buzzerPin, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  Serial.begin(9600);
}

// The loop routine runs over and over again forever:
void loop() {
  sensorValue = analogRead(analogInPin);
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\n");
  
  // Control other outputs based on sensor value
  if ((sensorValue >= 200) && (sensorValue <= 400)) {
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
  } else if ((sensorValue >= 401) && (sensorValue <= 500)) {
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
  } else if ((sensorValue >= 501) && (sensorValue <= 1000)) {
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
  } else {
    // Turn off all outputs if sensor value is out of range
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(buzzerPin, LOW); // Ensure buzzer is off
    return; // Exit the loop early
  }

  // Check if both LEDs (8 and 9) are HIGH to control the buzzer
  if (digitalRead(8) == HIGH && digitalRead(9) == HIGH) {
    // Check the time to toggle the buzzer
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
      previousMillis = currentMillis; // Save the last time you toggled the buzzer
      buzzerState = !buzzerState; // Toggle the buzzer state
      digitalWrite(buzzerPin, buzzerState); // Set the buzzer to the new state
    }
  } else {
    // If either LED is off, ensure the buzzer is off
    digitalWrite(buzzerPin, LOW);
  }
}

This code reads the water level sensor value and controls the LEDs and buzzer based on the sensor readings. The buzzer toggles on and off at a set interval when both LEDs (connected to pins 8 and 9) are HIGH.