Anbu Kumar
Published

Social Distance Detector

Social distancing is a new way of life globally. Clip this device on ur belt and maintain social distancing.

IntermediateShowcase (no instructions)1 hour7,972
Social Distance Detector

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×1

Hand tools and fabrication machines

arduino ide

Story

Read more

Code

Social Distance Detector

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

Anbu Kumar

Anbu Kumar

18 projects • 40 followers
22 years of professional experience in Software Industry,Robotics and Electronics.

Comments