0% found this document useful (0 votes)
11 views

Flood Control

This document contains an Arduino code for a flood monitoring system using an LCD display, ultrasonic sensor, and a moisture sensor. The system measures distance to detect water levels and alerts users through a buzzer and LED when levels are critical. It also displays the moisture sensor's value and the distance on the LCD screen, indicating normal or high alert conditions based on the readings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Flood Control

This document contains an Arduino code for a flood monitoring system using an LCD display, ultrasonic sensor, and a moisture sensor. The system measures distance to detect water levels and alerts users through a buzzer and LED when levels are critical. It also displays the moisture sensor's value and the distance on the LCD screen, indicating normal or high alert conditions based on the readings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<LiquidCrystal.

h>

LiquidCrystal lcd(12,11,10,9,8,7);

const int trigPin = 3;

const int echoPin = 4;

int moi=2;

int buz=5;

int led=6;

long duration;

int distance;

int moi_val;

void setup() {

Serial.begin(9600);

lcd.begin(16,2);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("FLOOD ");

lcd.setCursor(0,1);

lcd.print("MONITORING...");

delay(2000);

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

pinMode(moi_val,INPUT);

pinMode(buz, OUTPUT);

pinMode(led, OUTPUT);
digitalWrite(buz,LOW);

digitalWrite(led,LOW);

void loop()

// Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance = duration * 0.034 / 2;

delay(500);

Serial.println(distance);

moi_val=digitalRead(moi);

delay(500);

Serial.println(moi_val);

lcd.clear();

lcd.setCursor(0,0);
lcd.print("MOI:");

lcd.setCursor(7,0);

lcd.print(moi_val);

lcd.setCursor(0,1);

lcd.print("LEVEL:");

lcd.setCursor(7,1);

lcd.print(distance);

delay(2000);

if(distance<10)

lcd.clear();

lcd.setCursor(0,0);

lcd.print("LEVEL INCREASED");

digitalWrite(buz,HIGH);

digitalWrite(led,HIGH);

delay(2000);

else if(moi_val==0)

lcd.clear();

lcd.setCursor(0,0);

lcd.print("FLOOD OCCUR..");

lcd.setCursor(0,1);

lcd.print("HIGH ALERT..");

digitalWrite(buz,HIGH);
digitalWrite(led,HIGH);

delay(2000);

else

lcd.clear();

lcd.setCursor(0,0);

lcd.print("NORMAL...");

digitalWrite(buz,LOW);

digitalWrite(led,LOW);

delay(1000);

delay(1000);

You might also like