#define trigger_wave 13
#define distance_echo 12
#define buzzer 14
unsigned int condition=0;
void setup()
{
Serial.begin(115200);
pinMode(trigger_wave, OUTPUT);
pinMode(distance_echo, INPUT);
pinMode(buzzer,OUTPUT);
}
void loop()
{
//send the wqave to m,easure the length and teh capacity of water
digitalWrite(trigger_wave, HIGH);
delayMicroseconds(10);
digitalWrite(trigger_wave, LOW);
// receiving wave to judge teh waterlevel and hit the buzzer
int duration = pulseIn(distance_echo, HIGH);
Serial.print("Distance in feet: ");
Serial.println((duration / 58)*0.3);
//now i hyave value 400 and average dam will be of 120 feet
//i ned to convert my values to 120 so
condition = (duration / 58)*0.3;
if(condition >= 90)
{
digitalWrite(buzzer,HIGH);
Serial.print("DAM WILL BE OPENED FLOW WARNING!!!!!!!!! ");
}
else if (condition<90)
{
digitalWrite(buzzer,LOW);
}
delay(1000);
}