Introduction: Automatic Hand Sanitizer

This instructable explains and shows in depth steps on how to build an automatic hand sanitizer circuit and code. This can be used for your home, public office, garage or even on a pole outside for everyone to use. This is a very simple yet versatile design you can also customize for it to suit your needs, for example if you have 2 bottles of hand sanitizer you can change the direction of the motor by pressing the push button.

I hope you have fun building your circuit and writing your code. If your stuck and need help please let me know and email me at

click the link for TinkerCad


  • Arduino Uno R3

  • Ultra Distance Sensor

  • Push Button

  • Potentiometer (500 kilo ohms)

  • H-Bridge Motor Driver

  • Photoresistor

  • 9 Volt Battery

  • 2 Resistors(10 kilo ohms)

  • DC Motor

  • LED

Step 1: Circuit

The circuit is very easy to make if you know what you're doing. First you need all the supplies which are listed at the top, then start by connecting all the wires from the Arduino. First the 5 volt pin to the positive point on the breadboard, and same with the ground pin, after that connect the rest of the pins starting with the ones on the H-bridge, then the button, and finally the UDS. next connect the wires from the H-bridge to ground, then to the DC motor, after the Arduino, dc motor, and H-bridge are connected, connect the push button, the potentiometer, and the two resistors. After that you can connect the LED and the photoresistor. finally connect the 9 volt battery and the last wire going to and from negative on the breadboard.

Step 2: Code

The first thing you're going to do is declare all the integer values, next type in the pin mode code which allows the circuit to stop, thirdly open your void setup and declare if the value is input or output and close the void setup. After that, start your void loop by typing the code where it allows the circuit to turn on the DC motor, after that start the if-else statements then close the loop. finally the circuit will not work without this part of the code so make sure you do it properly, and lastly take your time.

Step 3: Testing

The last thing you're going to do is test it. The first thing you need to do is make sure all your wires are in the right spot after that press “start simulation” then put the photo resistor to high then lastly turn on the distance sensor and if you want to change the direction simply press the button.

Arduino Contest 2020

Participated in the
Arduino Contest 2020