Hardi Kurnianto
Published

Social Distancing Reminders

This device that can help remind us to stay safe with a minimum distance

BeginnerShowcase (no instructions)1 hour958
Social Distancing Reminders

Things used in this project

Hardware components

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

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

sosial_distancing.ino

Arduino
const int trigPin = 4;
const int echoPin = 3;
long duration;
int distance;
int a=0;

void setup() 
 {
  pinMode(trigPin, OUTPUT);
  pinMode(5, OUTPUT); 
  pinMode(echoPin, INPUT); 
  Serial.begin(9600);
  }
void loop() {
    digitalWrite(trigPin, LOW);delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    distance= duration/58.2;
    Serial.println(distance);
    delay(100);
         if(distance<=100){digitalWrite(5, HIGH);}
    else if(distance> 100){digitalWrite(5, LOW);}
    }

Credits

Hardi Kurnianto

Hardi Kurnianto

17 projects • 16 followers
Master student at Intelligent Control and Systems Engineering Department

Comments