Hello,

In this tutorial-based article, we are going to learn how to make an automatic hand sanitizer dispenser using Arduino.

Hardware Required

Software Required

 

  • Hand hygiene plays a very important role in response to all diseases, especially to Covid-19. One must wash their hands with water and soap for at least 20 seconds to clean out germs from their hands. But soap and water are not accessible to people in certain situations like when they are out of their homes and water is not available, or when they have dry skin so washing hands a lot of times during the day is not feasible. That is when hand sanitizers are the perfect alternative to washing their hands. 
  • During the Covid-19 era, the use of hand sanitizers has shot up exponentially. People were told to wash their hands now and then. They were also told to strictly avoid touching their face. But washing hands so many times a day is also not possible as it would erode the layer of skin. That is when the government issued the guidelines to use sanitizer when washing your hands is not possible. 
  • Alcohol-based hand sanitizers and face masks have become a part of our daily necessities after the pandemic. They have been essential in fighting this pandemic.  

Circuit Diagram

  • The circuit diagram for this dispenser contains 4 main components: The pump, Arduino board, Ultrasonic sensor, and the power supply adapter. Also, the transistor connected to the pump is used as a switch. 
  • The positive terminal on the pump is connected to the adapter and the negative is connected to the adapter via a transistor (switch). Further, the signal pin of the transistor is connected to the digital pin 2 of Arduino. 
  • The positive terminal of the adapter is also connected to the VIN pin on Arduino and the negative terminal to the GND pin. 

Pins on Ultrasonic sensor

Pins on Arduino Uno

VCC

5V

GND

GND

TRIG

D3

ECHO 

D4

Working principle of the dispenser

  • This flowchart. Illustrates the logic behind dispensing the sanitizer. After turning on the ultrasonic sensor, the sensor starts looking at if there are any objects around its vicinity. Whatever the case, the sensor will send the data back to the Arduino board. 
  • In case there are no objects in the vicinity, the Arduino board will not give out any commands. 
  • As soon as there is any object in the vicinity of the ultrasonic sensor, it will give the command to the Arduino. Furthermore, the ultrasonic sensor will send data about how far that object is situated. The point behind this is to decide a threshold distance below which the Arduino will give the command to pump out the sanitizer. 
  • So when the object in the vicinity of the ultrasonic sensor comes below the threshold, the Arduino board will give the command to pump out the sanitizer. This is done by switching on the transistor switch which is connected to the Arduino board. 
  • For storing the sanitizer, you can choose a case of your liking. Just make sure the pump is working properly and able to pump out the sanitizer via a pipe.

Arduino code

  • The code for the automatic hand sanitizer dispenser is given below.
int pump=2;
int trig_Pin=3;
int echo_Pin=4;
long Time;
int distance;
void setup() {
Serial.begin(9600);
pinMode(trig_Pin,OUTPUT);
pinMode(echo_Pin,INPUT);
pinMode(pump,OUTPUT);
}
void loop() {
digitalWrite(trig_Pin,LOW);
delayMicroseconds(2);
digitalWrite(trig_Pin,HIGH);
delayMicroseconds(10);
digitalWrite(trig_Pin,LOW);
Time=pulseIn(echo_Pin,HIGH);
distance=Time*0.034/2;
Serial.print("Distance:");
Serial.println(distance);
if(distance<15)
{
  digitalWrite(pump,HIGH);
}
else
{
  digitalWrite(pump,LOW);
}
}
  • Upload the code. Perform the circuit diagram

Now your Automatic hand sanitizer dispenser is ready to use.