Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Akshay Joseph
Published © GPL3+

COVID - 19 Automatic Hand Sanitizer

Automatic hand sanitizer bottle using Arduino and Servo Motor

BeginnerProtip64,266
COVID - 19 Automatic Hand Sanitizer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
Jumper wires (generic)
Jumper wires (generic)
×1
12v Adapter
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Mini Side Cutter, 120mm Length with 25mm Jaw Capacity
Mini Side Cutter, 120mm Length with 25mm Jaw Capacity

Story

Read more

Schematics

Automatic hand sanitizer

Code

Automatic hand sanitizer

Arduino
#include<Servo.h>
#define echoPin 4
#define trigPin 5
Servo Myservo;

int long duration;
int distance;
void setup(){ 
Myservo.attach(3);
pinMode(echoPin,INPUT);
pinMode(trigPin,OUTPUT);

}

void loop()
{
digitalWrite(trigPin,LOW);
delayMicroseconds(2); 
digitalWrite(trigPin,HIGH);
delayMicroseconds(10); 
digitalWrite(trigPin,LOW);
duration=pulseIn(echoPin,HIGH);
distance=(duration*0.034/2);
  
  if(distance<=5){
Myservo.write(180);
}
else {
Myservo.write(0);


}
  delay(500);

}

Credits

Akshay Joseph

Akshay Joseph

25 projects • 157 followers
B.Sc. Electronics Student at Govt. College Tanur

Comments