two hands with hand sanitizer

Corona virus is a very deadly virus that is claiming the lives of thousands of people globally. It started in Wuhan, China and quickly spread to rest of the world. Currently at the time of writing this post there is no known cure of the virus, however there are ways of reducing the risk of infection.

Among the ways is the use of alcoholic hand sanitizer which will greatly reduce the risk. Other measures against corona are listed here.

Hardware Requirements

The hardware component required for project are;

  • Microcontroller (Arduino uno)
  • Proximity Sensor
  • Mechanical Valve
  • Power Supply
  • Liquid Container
  • Relay Module

Arduino Uno is not the best micro-controller/ development board for this project but I chose it because it is relatively easy to program. Another advantage is the large growing community and it is newbie-friendly. You can find one here if you are new to the embedded system you can read about the Arduino here.

For the proximity sensor, you can decide to use an infrared motion sensor which can detect living body. Or an ultrasonic sensor which will detect anything withing a certain threshold range. You can also make use of light-dependent resistor (LDR) with a laser diode. Each and every thing has their pros and cons sometimes to compliment for the cons you can use to simultaneously. I like working with an ultrasonic sensor so I decided to use it, feel free to use any sensor of your choice.

The mechanical valve is responsible for opening and closing. For the mechanical valve, there are two options either I use a passive valve or an active valve. Because of the cost of active valve is higher than passive valve. Consequently I decided to use a passive valve

The Relay Module is needed to interface the valve to the arduino. Usually most mechanical actuators are rated at 12v. Generally micro-controller use logic voltage of 5v or below, and the Arduino is no exception.

As a result of these voltage differences we need an inter-mediate component. There are alot of component one can use to compensate for voltage differences. But for our purpose we are going to use this relay module.

one channel relay module

The power supply is the most important aspect of embedded design, fortunately, enough the Arduino development board has taken care of all the mathematically calculations for us. Hence we just need to adhere to their guidelines for powering the Arduino. The guidelines clearly indicate that anything from 7 to 12 volts can work with the Arduino. Mind you if you are working with higher voltage go for smaller current power supply adapter. Lower voltage tends to reduce heating of the onboard voltage regulator. My lucky voltage is 9volt, I have been using them for a while without any problem. For the current, I normally choose between 1 to 1.5 amps.

Circuit Diagram

Like any other engineering construction; you need a schematic diagram to guide you along the way. After selecting your components the first you need to do is draw your schematic.

Circuit Diagram Of an Automatic Hand Sanitizer Dispenser
Circuit Diagram Of an Automatic Hand Sanitizer Dispenser

The circuit is pretty straight forward

Liquid Container

This is the one thing you should not worry too much about. you just need something you can feel up easily at one end and attach a valve at the other end. keep in mind that if you are using a passive valve the container needs to be directly above the valve as possible.


Here is the code for the project do let us know if you have any problem in the comment section or via telegram with the header phone number. Or make use of our official email:

/* The code makes no use of any library so it should compile without any errors
the sensor has a trimer which can be used to adjust the distance for detection.
follow the circuit diagram for connections */
int sensor_pin = 3;
int valve = 5;

void setup() {
  pinMode(valve, OUTPUT);  // sets the digital pin 5 as output
  pinMode(sensor_pin, INPUT);    // sets the digital pin 2 as input

void loop() {
  val = digitalRead(sensor_pin);   // read the input pin
if (val == HIGH)
  digitalWrite(valve, HIGH);  // sets the LED to the button's value

There you have the code for automatic hand sanitizer dispenser simple and straight forward.

Thanks for reading this article,i will be posting another soon to explain the working principle keep checking the website

Leave a Reply