Flood warning systems

TLMXB005

While on a school picnic, Jugaadu saw an accident. A bridge collapsed due to the heavy traffic during the rainy season. As the water level increases above the danger sign and people driving were not aware of it. Jugaadu decided to make a system that can alert people during such circumstances. Can you help Jugaadu?
Architect and IoT Kit
  1. Make a bridge prototype by Architecture kit and put it in water assuming real-life scenarios.
  2. Hang connecting wires at different levels of the bridge.
  3. Connect RGB LED and Buzzer, battery with the hanging wires with Arduino on the breadboard.
  4. Program the Arduino and test it.

    

#include <Servo.h>

Servo myservo;

int rainsens = A0;

int pos = 0;

int buzzer=11;

int red=7;

void setup() {

Serial.begin(9600);

myservo.attach(9);

pinMode(buzzer,OUTPUT);

pinMode(red,OUTPUT);

digitalWrite(buzzer,HIGH);

}

void loop() {

int sensorValue = analogRead(rainsens);

sensorValue = map(sensorValue, 0, 1023, 0, 180); 

if (sensorValue >= 30 && sensorValue <38) {

digitalWrite(red,HIGH);

delay(2000);

for (pos = 0; pos <= 90; pos += 1) {

myservo.write(pos);

delay(100);

}}

else if (sensorValue>=40 && sensorValue<=45){

digitalWrite(buzzer,HIGH);

//myservo.write(0);

}

else if(sensorValue>=120 ){

myservo.write(0);

digitalWrite(buzzer,LOW);

digitalWrite(red,LOW);

Serial.println(sensorValue);

delay(20);

}

}