Devices & Components
Arduino Uno Rev3
Ultrasonic Sensor - HC-SR04 (Generic)
PIR Sensor, 7 m
DC Motor, 12 V
LED Light Bulb, Frosted GLS
Project description
Code
Social Distancing hand wash dispenser
arduino
This is a simple circuit made of two main components:- am ultrasonic sensor and a PIR and of course an arduino. This is a simple yet ingenious way to keep your hands clean in an outdoor place while keeping your sanity maintained
1int pir=0; 2int sensor=0; 3long readUltrasonicDistance(int triggerPin, int echoPin) 4{ 5 pinMode(triggerPin, OUTPUT);//Clear the trigger 6digitalWrite(triggerPin, LOW); 7 delayMicroseconds(2); 8//Sets the trigger pin to HIGH state for 10 milisecond(s) 9digitalWrite(triggerPin, HIGH); 10delayMicroseconds(10); 11digitalWrite(triggerPin, LOW); 12pinMode(echoPin, INPUT); 13//Reads the echo pin, and returns the sound wave travel time in microseconds 14 return pulseIn(echoPin,HIGH); 15} 16void setup() 17{ 18 pinMode(11,INPUT); 19 pinMode(6, OUTPUT); 20 pinMode(4, OUTPUT); 21 pinMode(3, OUTPUT); 22 Serial.begin(9600); 23} 24 25void loop() 26{ 27 pir=digitalRead(11); 28 sensor=0.0173*readUltrasonicDistance(13,12); 29 Serial.println(sensor); 30 delay(500);//Wait for 500 milisecond(s) 31 if(sensor<= 200){ 32 digitalWrite(3, HIGH); 33 if(sensor <= 20){ 34 if(pir==HIGH){ 35 digitalWrite(6, HIGH); 36 } 37 if(pir==LOW){ 38 digitalWrite(6, LOW); 39 } 40 } 41 } 42 else{ 43 digitalWrite(6, LOW); 44 digitalWrite(3, LOW); 45 46 47 } 48}
Social Distancing hand wash dispenser
arduino
This is a simple circuit made of two main components:- am ultrasonic sensor and a PIR and of course an arduino. This is a simple yet ingenious way to keep your hands clean in an outdoor place while keeping your sanity maintained
1int pir=0; 2int sensor=0; 3long readUltrasonicDistance(int triggerPin, 4 int echoPin) 5{ 6 pinMode(triggerPin, OUTPUT);//Clear the trigger 7digitalWrite(triggerPin, 8 LOW); 9 delayMicroseconds(2); 10//Sets the trigger pin to HIGH state for 10 11 milisecond(s) 12digitalWrite(triggerPin, HIGH); 13delayMicroseconds(10); 14digitalWrite(triggerPin, 15 LOW); 16pinMode(echoPin, INPUT); 17//Reads the echo pin, and returns the sound 18 wave travel time in microseconds 19 return pulseIn(echoPin,HIGH); 20} 21void 22 setup() 23{ 24 pinMode(11,INPUT); 25 pinMode(6, OUTPUT); 26 pinMode(4, OUTPUT); 27 28 pinMode(3, OUTPUT); 29 Serial.begin(9600); 30} 31 32void loop() 33{ 34 35 pir=digitalRead(11); 36 sensor=0.0173*readUltrasonicDistance(13,12); 37 Serial.println(sensor); 38 39 delay(500);//Wait for 500 milisecond(s) 40 if(sensor<= 200){ 41 digitalWrite(3, 42 HIGH); 43 if(sensor <= 20){ 44 if(pir==HIGH){ 45 digitalWrite(6, 46 HIGH); 47 } 48 if(pir==LOW){ 49 digitalWrite(6, LOW); 50 } 51 52 } 53 } 54 else{ 55 digitalWrite(6, LOW); 56 digitalWrite(3, LOW); 57 58 59 60 } 61}
Downloadable files
Social Distancing hand wash dispenser
This is a simple circuit made of two main components:- am ultrasonic sensor and a PIR and of course an arduino. This is a simple yet ingenious way to keep your hands clean in an outdoor place while keeping your sanity maintained.
Social Distancing hand wash dispenser

Comments
Only logged in users can leave comments