int trigger_pin=3;
int echo_pin=2;
int time;
int dis;
void setup()
{
Serial.begin(9600);
pinMode(trigger_pin,OUTPUT);
pinMode(echo_pin,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
}
void loop()
{
digitalWrite(trigger_pin,HIGH);
delayMicroseconds(500);
digitalWrite(trigger_pin,LOW);
time=pulseIn(echo_pin,HIGH);
dis=(time*0.034)/2;
Serial.println(dis);
if(dis<=212)
{
Serial.println("No Danger.....!!");
Serial.println("PARTY MUST GO ON....!!");
digitalWrite(7,LOW);
digitalWrite(6,LOW);
digitalWrite(5,HIGH);
digitalWrite(4,LOW);
}
if(dis<=133)
{
Serial.println("ALERT .....!!");
Serial.println("PARTY MUST GO ON.....!!");
digitalWrite(7,LOW);
digitalWrite(6,HIGH);
digitalWrite(5,LOW);
digitalWrite(4,LOW);
}
if(dis<=36)
{
Serial.println("WARNING .....!!");
Serial.println("STOP PARTY .....!!");
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);
digitalWrite(5,LOW);
digitalWrite(4,LOW);
}
}