0% found this document useful (0 votes)
2 views4 pages

Arduino Program for Water Level Monitoring

This document outlines an Arduino project for monitoring water levels using a water level sensor, displaying results on the Serial Monitor. It includes required components, circuit connections, and detailed Arduino code with explanations for setup and loop functions. The code categorizes water levels into low, medium, and high, and provides a delay for stability between readings.

Uploaded by

22cs177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Arduino Program for Water Level Monitoring

This document outlines an Arduino project for monitoring water levels using a water level sensor, displaying results on the Serial Monitor. It includes required components, circuit connections, and detailed Arduino code with explanations for setup and loop functions. The code categorizes water levels into low, medium, and high, and provides a delay for stability between readings.

Uploaded by

22cs177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Arduino Program for Water Level

Monitoring
This project will use a water level sensor to detect water levels and display the results on the
Serial Monitor. We can extend this to trigger alarms, control pumps, or display readings on an
LCD.

🛠️ Required Components
1. Arduino Uno (R3)
2. Water Level Sensor
3. Jumper Wires
4. Breadboard (Optional)
5. Buzzer (Optional, for alerts)

🔌 Circuit Connections
Water Sensor Pin Arduino Pin
VCC (Power) 5V
GND (Ground) GND
A0 (Analog Output) A0

(A0 outputs an analog value that changes based on water level.)

📜 Arduino Code
#define WATER_SENSOR_PIN A0 // Define the analog pin for water sensor

void setup() {
Serial.begin(9600); // Start Serial Monitor
Serial.println("Water Level Monitoring Started");
}

void loop() {
int waterLevel = analogRead(WATER_SENSOR_PIN); // Read analog value from
the sensor
Serial.print("Water Level: ");
Serial.println(waterLevel); // Print the sensor value

// Define water level conditions


if (waterLevel < 200) {
Serial.println("Water Level LOW! ⚠️");
}
else if (waterLevel >= 200 && waterLevel < 500) {
Serial.println("Water Level MEDIUM 🟡");
}
else {
Serial.println("Water Level HIGH! 🚰");
}

Serial.println("-------------------");
delay(2000); // Wait 2 seconds before next reading
}

📖 Code Explanation
1️⃣ Define Sensor Pin
cpp
CopyEdit
#define WATER_SENSOR_PIN A0

 We define A0 as the pin where the water sensor is connected.

2️⃣ Setup Function


cpp
CopyEdit
void setup() {
Serial.begin(9600);
Serial.println("Water Level Monitoring Started");
}

 Start Serial Communication at 9600 baud.


 Print a startup message.

3️⃣ Loop Function


cpp
CopyEdit
int waterLevel = analogRead(WATER_SENSOR_PIN);

 Read the sensor value from A0.


 The sensor outputs higher values when water level is high.
4️⃣ Display Water Level
cpp
CopyEdit
Serial.print("Water Level: ");
Serial.println(waterLevel);

 Print the water level value on the Serial Monitor.

5️⃣ Set Water Level Conditions


cpp
CopyEdit
if (waterLevel < 200) {
Serial.println("Water Level LOW! ⚠️");
}
else if (waterLevel >= 200 && waterLevel < 500) {
Serial.println("Water Level MEDIUM 🟡");
}
else {
Serial.println("Water Level HIGH! 🚰");
}

 LOW (Below 200): Water is low.


 MEDIUM (200-500): Water is at a moderate level.
 HIGH (Above 500): Water is at a high level.

6️⃣ Delay for Stability


cpp
CopyEdit
delay(2000);

 Wait 2 seconds before the next reading.

📟 Output on Serial Monitor


1. Upload the Code to Arduino.
2. Open Serial Monitor (Baud Rate: 9600).
3. You will see:

markdown
CopyEdit
Water Level: 150
Water Level LOW! ⚠️
-------------------
Water Level: 350
Water Level MEDIUM 🟡
-------------------
Water Level: 700
Water Level HIGH! 🚰

You might also like