Hdac
Published © Apache-2.0

The Social Distancer

A simple mask add on to keep people away.

IntermediateShowcase (no instructions)774
The Social Distancer

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
Tilt Switch, SPST
Tilt Switch, SPST
×1
Buzzer
Buzzer
×1
5 mm LED: Red
5 mm LED: Red
×1

Hand tools and fabrication machines

Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)

Story

Read more

Code

Simple code

Arduino
It is code. Quite simple because most of the logic is in the circuitry.
int trigPin = 10;
int echoPin = 11;
int Buzzer = 12;


void setup() {
  Serial.begin(9600);
   pinMode(Buzzer, OUTPUT);
   pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);


}

void loop() {
  long duration, distance;
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance =(duration/1)/29.1;
   duration=pulseIn(echoPin, LOW);
  Serial.print(distance);
  Serial.println("cm");
  delay(10);

 if((distance<=45))
  {
    digitalWrite(Buzzer, HIGH);
}
   else if(distance>45)
 {
     digitalWrite(Buzzer, LOW);
   }
}

Credits

Hdac

Hdac

0 projects • 0 followers

Comments