DanielKang21
Published © GPL3+

The Arduino social - distancing sensor

The Arduino social - distancing sensor regulates social distancing through an ultrasonic sensor and an LED.

BeginnerShowcase (no instructions)35,943
The Arduino social - distancing sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SparkFun Solder-able Breadboard - Mini
SparkFun Solder-able Breadboard - Mini
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

3d Printable casing for the social - distancing sensor

Schematics

Tinkercad model of circuit

Code

Social distancing sensor code

Arduino
int trigger_pin = 2;

int echo_pin = 3;

int buzzer_pin = 10; 

int time;

int distance; 




void setup ( ) {

        Serial.begin (9600); 

        pinMode (trigger_pin, OUTPUT); 

        pinMode (echo_pin, INPUT);

        pinMode (buzzer_pin, OUTPUT);

        pinMode(13, OUTPUT);



}




void loop ( ) {

    digitalWrite (trigger_pin, HIGH);

    delayMicroseconds (10);

    digitalWrite (trigger_pin, LOW);

    time = pulseIn (echo_pin, HIGH);

    distance = (time * 0.034) / 2;

    

  if (distance <= 50) 

        {


        Serial.print (" Distance= ");              

        Serial.println (distance);        

        digitalWrite(13, HIGH);

        delay (500);

        }

  else {
\

        Serial.print (" Distance= ");              

        Serial.println (distance);        

        digitalWrite(13, LOW);

        delay (500);        

  } 

  }

Credits

DanielKang21

DanielKang21

0 projects • 4 followers

Comments