Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
snehiludrhj
Published © GPL3+

Handsfree Liquid Handwash Dispenser

This is a position sensored handswash dispenser, using ultrasonic waves to detect hand, and dispense liquid, without touching dispenser.

BeginnerFull instructions provided491
Handsfree Liquid Handwash Dispenser

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

Circuit Diagram #1

representing connection of sensor, arduino & servos.

Code

Arduino IDE code

Arduino
#include <Servo.h>
/*contains 
 * attach()
 * write()
 * writeMicroseconds()
 * read()
 * attached()
 detach()*/
#define trigPin 3
#define echoPin 2


Servo servo1;
Servo servo2;
int sound = 250;

void setup() 
    {
        Serial.begin (9600);
        pinMode(trigPin, OUTPUT);
        pinMode(echoPin, INPUT);
        servo1.attach(4);
        servo2.attach(5);
    }
void loop() 
    {
        long duration, distance;
        digitalWrite(trigPin, LOW);
        delayMicroseconds(2);
        digitalWrite(trigPin, HIGH);
        delayMicroseconds(10);
        digitalWrite(trigPin, LOW);
        duration = pulseIn(echoPin, HIGH);
        distance = (duration/2) / 29.1;
        if (distance < 5) 
            {
                Serial.println("the distance is less than 5, dettol liquid dispensed");
                servo1.write(100);
                /*will rotate servo1 to 100degress clockwise*/
                servo2.write(100);
                /*will rotate servo2 to 100degress clockwise*/
            }
        else  
            {  
                servo1.write(0);
                servo2.write(0);
                /*no effect on the two servos*/
            }
        if (distance > 60 || distance <= 0)
            {
              Serial.println("The distance is more than 60, move your hand closer");
            }
        else 
            {
              Serial.print(distance);
              Serial.println(" cm");
            }
      delay(500);
}

Credits

snehiludrhj
3 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.