About: An educational blog for engineering students in providing information on electronics projects, Arduino projects, Engineering projects, circuits & Ideas

In this time of coronavirus (COVID-19) spread hand sanitizing is must and for this people also touches the bottle of hand sanitizers so to prevent it here is another great Arduino based project, which is automatic hand sanitizer dispenser. Pumping of the head of bottle means making contact with its surface, so to ensure safe distance it is a great solution in these time in which contamination is very fast Nowadays the need of hand sanitizer has increased to a great extent that every shop local place has availability to it but no protection so this cab used as a great solution to the uncontaminated and no-contact hand sanitizer mechanism.


It consists of various small and easy to available components like ARDUINO UNO, ULTRASONIC SENSOR, RGB LED, RELAY MODULE,12v WATER PUMP, 12v ADAPTER, and few other passive components.

This type of circuit can be fixed in any type of bottle or container so as to make it an automatic hand sanitizer one. The RGB led provide visual indicator of the stratus of the system which we will came to know in further working.

Here we have used ultrasonic sensor because if we use IR sensor than it won’t work properly in brighter or in sunlight areas, so as to define a specific distance and to make the system work flawlessly, we have used ultrasonic sensor.

12v pump is used for this project which is also first cleaned with some type of cleaning agent also wires are covered with heatsink to as to protect it from reaction with sanitizer. The system is powered with a 12v Adapter.

Relay module is used to turn on or off the pump with time and to provide complete 12v power supply to the pump as Arduino work on 5v.


  • Easy to make
  • Easy to use
  • Adjustable distance
  • Low price Can be in all places
  • Visual indicator


  • Any microcontroller preferably Arduino Uno for beginners.
  • An RGB led
  • An ultrasonic sensor
  • A breadboard
  • Jumper wires
  • 220ohm resistor
  • 12v Water pump
  • 12v Adapter
  • Pipe or tube for pump


First take the power lines onto the bread board from microcontroller VCC/5v-->+ line and GND--> - line.

Connect all vcc and gnd of sensor to Arduino 5v taken on Breadboard. Connect 12 v positive supply to relay IN port and from out port to 12v Water pump positive. And make gnd common with Arduino

And then make following connections: -


D3 ============> RELAY Signal pin

D4 ============> RED LED positive pin

D5 ============> GREEN LED positive pin

D9 ============> TRIG PIN (ultrasonic sensor)

D10 ============> ECHO PIN

Step 5: CODE

int RELAY = 3;

int RED_LED = 4;

int GREEN_LED = 5;

const int trigPin = 9;

const int echoPin = 10;

long duration;

int distanceCm, distanceInch;

void setup()



pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);





void loop() {

digitalWrite(trigPin, LOW);


digitalWrite(trigPin, HIGH);


digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distanceCm= duration*0.034/2;

distanceInch = duration*0.0133/2;

Serial.println("Distance: ");


if(distanceCm < 10)


digitalWrite(RELAY , HIGH);

digitalWrite(RED_LED , LOW);

digitalWrite(GREEN_LED , HIGH);




digitalWrite(RELAY , LOW);

digitalWrite(RED_LED , HIGH);

digitalWrite(GREEN_LED , LOW);




As the code starts it initializes the pin to which various components are connected and Green LED starts to glow which indicates that the system is ready to use for. Then ultrasonic sensor checks the distance every 2 seconds to detect if someone arrived or not than it waits for 2 seconds and after that turns on the water pump by turning relay on along with changing the status led to RED which shows wit for the liquid to dispense. After the specific amount of liquid is dispensed the pump is turn off and status led turns to blue which indicates specific amount of liquid is dispense and it is sufficient for single use. The led won’t turn red until the person moves out of the range specified ultrasonic sensor. Later as soon as person moves out the led status turns to red and system is again ready to be used.


Now as we have developed our circuit and ordering it. For ordering PCB, I would prefer you NextPCB which is a great website for ordering custom PCB with high quality and precision on time delivery. Ordering PCB online in various sites are a step towards developing our own circuit. NextPCB provides very easy and fast delivery of PCB in different masks and paste with professional look. Also, they send you the picture of your PCB before shipping it to you, Now that very exciting….The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from :Gerber Viewer of NextPCB

Go to get your discount: NextPCB

#arduino #arduinouno #arduinoproject #arduinomega #arduinonano #arduino duo