Diy Electronic
Published © GPL3+

Social distancing alarm using arduino

Hey guys, welcome back I hope you all are well so in this project we will make a social distancing alarm using Arduino.

BeginnerFull instructions provided1 hour1,495
Social distancing alarm using arduino

Things used in this project

Story

Read more

Schematics

Social distancing alarm using arduino

Code

Social distancing alarm using arduino

C/C++
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
void setup()
{
Serial.begin(9600); 
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
Serial.println("Distance: ");
Serial.println(distanceCm);

if(distanceCm < 100)
{
  digitalWrite(11,HIGH);
  digitalWrite(12,HIGH);
}
else 
{
  digitalWrite(11,LOW);
  digitalWrite(12,LOW);
}
}

Credits

Diy Electronic

Diy Electronic

3 projects • 4 followers
I love to do Electronic & Electrical Experiment.

Comments