Door collision alert system

TLMXB007

In Jugaadu’s office, there is a single hinged door for both entrance and exit. One day while he was entering and his colleague was exiting at the same time, Jugaadu hit his head. After this incidence, he decided to make something to avoid such accidents. Can you help Jugaadu?
Design and Digital kit
  1. Make a door using a 3D printer.
  2. Place two US sensors, one at the entrance of the door and second at the exit .
  3. Connect US modules with Arduino, switch, battery and Buzzers, RGB LEDs using connecting wires on bread-board.
  4. Program the Arduino and upload the sketch Using A to B USB Cable.
  5. Test it by power it on.

    

double trigPin1=2;

double echoPin1=3;

double trigPin2=4;

double echoPin2=5;

int buz=11;

void setup(){ 

Serial.begin (9600);

pinMode(trigPin1, OUTPUT);

pinMode(echoPin1, INPUT);

pinMode(trigPin2, OUTPUT);

pinMode(echoPin2, INPUT);

pinMode(buz, OUTPUT);

}

void loop(){ 

long duration1, distance1;

digitalWrite(trigPin1, LOW); // Added this line

delayMicroseconds(2); // Added this line

digitalWrite(trigPin1, HIGH);

delayMicroseconds(10); // Added this line

digitalWrite(trigPin1, LOW);

duration1 = pulseIn(echoPin1, HIGH);

distance1 = (duration1/2) / 29.1;

if (distance1 <5){

digitalWrite(buz,HIGH);

Serial.println("someone is coming");

}

else {

digitalWrite(buz,LOW);

}

long duration2, distance2;

digitalWrite(trigPin2, LOW); // Added this line

delayMicroseconds(2); // Added this line

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10); // Added this line

digitalWrite(trigPin2, LOW);

duration2 = pulseIn(echoPin2, HIGH);

distance2= (duration2/2) / 29.1;

if (distance2 <5){

digitalWrite(buz,HIGH);

Serial.println("someone is coming");

}

else {

digitalWrite(buz,LOW);

}

}