DIY Hand Sanitizer Dispenser (Leonardo Arduino)
by Mitch2007 in Circuits > Arduino
174 Views, 0 Favorites, 0 Comments
DIY Hand Sanitizer Dispenser (Leonardo Arduino)
Intro:
The design was inspired by a product presented on Instructable called "DIY Hand Sanitizer Dispenser" (https://www.instructables.com/DIY-Hand-Sanitizer-Dispenser-Using-Arduino/). But now, minimize change is done to the original product. A paper roll is added beside the product, and the height of the sensor also changed due to the different sizes for the products compare to the original one. Same with the original product, this product was main to resolve the problem of COVID-19.
Supplies
The materials are
Electronics:
x1 Leonardo Arduino( or any Arduino )
x1 Ultrasonic Sensor ( HC-SR04)
x1Servo Motor ( metal Geared Preferred )
x 20 above Jumper Wires ( female to female )
x1Hot Glue Gun.
x1Computer or Laptop.
x1Spray bottle
x1Self Threading Screw ( 1 pcs).0.8 mm copper wire ( 0.5 meters)
x1 Scissors
x1 ruler
x1 marker
x1 utility knife
x1 copper wire
x1 box plastic container ( which fits everything inside comfortably)Stationary ( marker and ruler scale ).
Step 1: Setting Up the Board
Sensor to Arduino:
Trigger to D10 Echo to D11 Vcc to Vcc Gnd to Gnd
Servo to Arduino:
Signal to D9 Vcc to Vin Gnd to Gnd
Step 2: Cut Hot Glue Stick With Hole in Middle
Drill a hole in between a small piece of hot glue stick by using the unify knife, then use the copper wire to go through it, then tie the copper wire onto the servo.
Step 3 : Box
1.Drill a hole on the side of the box line up the hole with the servo, then place the screw into the hole.
2. Use the hot glue gun to stick the servo opposite side as the screw and line up with it.
3. Attach the wire onto the screw and onto the servo.
Step 4: Arduino and Sensor
Place the Arduino inside the box beneath the servo
Drill two holes on the cover of the box for placing the sensor on it
And Drill one big hole at the size of the spray bottle
After placing the spray bottle, place the piece of hot glue that attaches with the copper wire onto the top.
Step 5: Paper Roll (optional)
Use the left copper wire to make a small paper roll that can attach the side of the box.
Step6: Coding
const int servo = 9; //define Servo Signal Pin
const int trigPin = 10; //define Trigger Pin const int echoPin = 11; //define Echo Pin
// defines variables
long duration; int distance;
#include
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input myservo.attach(servo); // attaches the servo on pin 9 to the servo object myservo.write(0); // Sets Servo to initially 0 degrees Serial.begin(9600); // Starts the serial communication }
void loop() { // digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); //Servo if(distance<15) //改 myservo.write(45); // Sets Servo in stages from 0 to 180 degrees so soap does not pitch out. delay(100); myservo.write(90); delay(100); myservo.write(135); delay(100); myservo.write(120); //Ajust how far you want the servo to go. delay(1000); myservo.write(00); // Reset the servo to 0 Degrees delay(2500); //Delay the next time someone can get soap }
Link: https://create.arduino.cc/editor/michellelin888888/f31610b1-59f9-4d4d-8b91-1fabf37af8ee/preview