Aarav Barnwal
Published © GPL3+

Wearable Social Distance Detector Gadget

A well-built ultrasound-based Arduino-programmed social distance detector, which can be helpful in this dreadful corona virus crisis.

IntermediateShowcase (no instructions)1,102
Wearable Social Distance Detector Gadget

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Buzzer
Buzzer
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Black
Tape, Black

Story

Read more

Schematics

Wearable Social Distance Detector Gadget Circuit Diagram

Code

Wearable Social Distance Detector Gadget Code

Arduino
// created by aarav_barnwal
// created on 2nd May 2020
// name-- wearable social distance detector gadget 
#define echoPin 2 
#define trigPin 3 

// defines variables
long duration; 
int distance; 
void setup() {
  pinMode(11,OUTPUT);
    
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT); 
  Serial.begin(9600); 
  Serial.println("Ultrasonic Sensor HC-SR04 Test for social distance detector"); 
  Serial.println("with Arduino UNO R3");
  
}
void loop() {
  
 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);
 
  distance = duration * 0.034 / 2; 
  
  delay(100);
  
 
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
      
  if (distance < 182.88) {
      digitalWrite(11, HIGH);
    } else {
      digitalWrite(11, LOW);
    }
   
  }

Credits

Aarav Barnwal

Aarav Barnwal

1 project • 0 followers

Comments