Automatic Hand Sanitizer

Introduction: Automatic Hand Sanitizer

The COVID-19pandemic has become something that the public has heard very often during 2020. Every citizen who hears the word “COVID-19” will immediately think of the word “Dangerous”, “Deadly”, “Keep Clean”, and other words. This COVID-19 has also been declared a pandemic and many countries have suffered losses from this pandemic, both in the economic and health sectors. This pandemic is spreading very quickly and to prevent it, people need to maintain their health by maintaining cleanliness, maintaining distance from others, and staying at home.

In this new normal era, various places have been opened but not all of them have the same cleaning facilities, some provide handwashing facilities but they are not hygienic, some provide hand sanitizers but hundreds of people have touched us, we don't know if they infected COVID-19 or not. The existence of cleanliness facilities in the era of COVID-19 makes people think twice about whether to come or not to that location.

With the Automatic Hand Sanitizer, business owners no longer need to be afraid of this because automatic hand sanitizers can be used by many people without being touched which obviously means that they are very hygienic and will increase the number of people who come to the business location because they have good hygiene facilities.

Step 1: Online Simulation

The simple concept in this project is when the HC-SR04 detects any object at a certain distance, it will send a signal to the Arduino then the Arduino will turn on the water pump to make the DC water pump dispense the hand sanitizer. In the circuit above, the DC motor is the water pump in the real project.

We all know, sometimes it's not easy working with electronics. There might some error during the project and the debugging process sometimes takes less time but also sometimes take a lot of time to think. To reduce any error we should test the project in online simulation first. In this project, I’m using Tinkercad to simulate my circuit so then during the physical design, there's not a lot of error.

You can take a look at the Tinkercad file at the link below:

Step 2: Prepare Your Component & Test It

For making this project, we need:

  • Arduino Uno
  • 9V Battery
  • HC-SR04 Ultrasonic Sensor
  • 5V DC Water Pump (DC Motor in Tinkercad)
  • Transistor NPN
  • 1k Ohm Resistor


  • LCD (For better UI)
  • Potentiometer (if use LCD)
  • 330 Ohm Resistor (if use LCD)
  • Green & Yellow LED (For better UI & you can change the color)
  • 2x 330 Ohm Resistor (if use LED)

If you got all the components ready, now let’s build the project!

I would recommend you to test all the components first so if there’s an error during simulation, there are no more possibilities any individual component is the problem. I'm gonna describe in short how to test each component:

  • Arduino Uno: Open Arduino IDE, go to the FILE>Example>Basic>Blink. If the LED in the Arduino blink, it means it working.
  • HC-SR04 Sensor: Attach the VCC, Ground, Echo, and Trigger Pin such as the circuit and coding in the image above. Try to simulate it, open the Serial Monitor, and put your hand near/far the sensor. If it prints any various number, it means it working. I will explain the meaning of the number in the next step.
  • DC Water Pump: Attach the pin such as the circuit above to the battery. If there's a vibration sound, means the component ready to go.
  • LCD: Attach all the pins to the Arduino such as the circuit above. Copy the code and try to compile it. If it prints the text, means to component work well.
  • LED: Attach the LED pins such as the circuit above to the battery. If the LED is turned on, means the component working.

Step 3: Design Physical Circuits

After you know all the components working well, we continue to the most fun part, build all the circuits. Sorry for the little messy in the picture, but I'm sure you can see clearly which circuit goes to VCC, ground & Arduino Pin in the Tinkercad circuit.

Because we already simulate the project in Tinkercad, we can follow the circuit in the picture above and test whether it is working or not. If you are interested to know why this pin goes to this pin and other about circuit explanation, I attached a video at the end of the project for a more detailed explanation.

After all the circuit build, we will go through the coding step, the next step.

Step 4: Programming Arduino

To code the Arduino, you can open Arduino IDE and choose the port and board type you have in the tools menu. Then, you can copy my coding file attach below and compile it to your Arduino.


Please take off all the battery during the Arduino connected to the computer. Don’t connect your Arduino to any external power supply. There’s a possibility your project will be overpowered and might break your circuit, computer port, or any other things related.

If you are interested in how the coding makes it work, you can watch the video I attached at the end of the project because I explain in detail how to write the code.

Step 5: Reading the HC-SR04 Ultrasonic Sensor

I put this step separately with others because I think this is the most crucial part of the project. This project depends on the sensor and if you wrong to read the sensor, the project won't work well.

As you see in the above picture, I set the distance in 4 inches which means when the sensor ping read below 4 inches, it will send the signal and make the water pump turned on and dispense hand sanitizer. You can change the distance target detection based on your project.

Step 6: Try the External Power Supply

After the code is compiled to the Arduino, the distance detection of the sensor is also set. We can try to use it for real applications. Attach all the external power supply. In my case, I used a 4 X 1.5V battery for Arduino and a 9V of battery for the DC Pump.

If the project is working well, congrats!

The last step is to design the case so it could be used by anyone.

Step 7: Casing Design

Sorry for some messy casing design, currently because of the pandemic, I just able to use a few items I have in my house.

I would recommend you to print PCB in this project to have a better design and also 3D print the casing. In my case, because of limitations, I only have cardboard and tape. But the project working so well though, it never misses any detection and it never detects any ghost which means the sensor reading working perfectly.

I also suggest you design the casing with a room for the userto refill the hand sanitizer and debugging for the engineer. In my case, you can see pictures number 3 and 4 where I make a room for the refill and debugging if there's any problem with the LCD, LED, or the HC-SR04 sensor.

Step 8: Use It!

After following all the steps above, I'm pretty sure you can make the project working well. I hope this project you make will not only decorate or impress anyone how smart you are. Instead, USE IT!

During my time in the organization, I always said to my team, it's not how busy matters, but how impactful are the matters. Any busyness without any impact you could bring to the world is a waste of time.

These Automatic Hand Sanitizers you make could give a lot of positive impacts on your environment. For me, I gave it to my family business owner so all the staff could use it and reduce any possibilities of COVID-19 infection.

I also attached a video of every detailed explanation about the circuit and coding, if you interested to know more, feel free to watch it! Link in the below:

Hope you like this tutorial and if you do so, please give a like to the project. Thank you and to see you in the next project!

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge



    Question 2 years ago on Step 1

    Nice project, it is my start with Arduino!!!
    but I have a problem, can you please renew the link?
    I receive this message on tinkercad:

    410 The share link has expired. To continue editing ask the owner for a new link

    Thank you in advance.


    Answer 2 years ago

    Sure! Link just updated. Goodluck with your project:)


    Reply 2 years ago

    can you please renew the link?
    I receive this message on tinkercad:

    410 The share link has expired. To continue editing ask the owner for a new link.

    Thank you in advance.


    2 years ago

    Nice project. Next time remember the batteries need to fit inside the enclosure. An easy thing to forget when just getting started with this. :)


    Reply 2 years ago

    Sure will, thanks for the advice! :)