herolivechannel
Published © LGPL

Fighting Corona: Multichoice automatic hand sanitizer

Make Automatic hand santinizer using ultrasonic sensor module, arduino uno and rc servo motor

BeginnerFull instructions provided11,974
Fighting Corona: Multichoice automatic hand sanitizer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
RC servo MG996R
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Drill, Screwdriver
Drill, Screwdriver

Story

Read more

Schematics

Automatic hanitizer Schematics

Code

Automatic hanitizer code

C/C++
#include <Servo.h>
int echoPin = 12;
int trigPin = 11;
int servoPin = 10;
int duration; //micro second
float d_cm;
int pos01=0;
int pos02 = 100;
Servo myServo;
void setup() {

// initialize serial communication:
  Serial.begin(9600);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  myServo.attach(servoPin);
  myServo.write(pos01);
}

void loop() {
  // generate pusle trigger
  digitalWrite(trigPin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  // receive 
  duration = pulseIn(echoPin,HIGH);
  d_cm = duration * 0.034/2.;
  //servo
  if(d_cm>=11 & d_cm<=14){
    for (int i=0;i<=pos02; i+=10){
      myServo.write(i);
      delay(15);
    }
    delay(400);
    myServo.write(pos01);
    delay(1000);
  }
  //print
  Serial.print("Distance:");
  Serial.print(d_cm);
  Serial.println("cm");
}

Automatic hanitizer Code

Credits

herolivechannel
0 projects • 11 followers
Contact

Comments

Please log in or sign up to comment.