In today’s world, maintaining hygiene has become extremely important, especially in public places, offices, schools and homes. Touch-based sanitizing systems can spread germs, which is why contactless smart dispensers are now widely used.
This project demonstrates how to build a Smart Sanitizer Dispenser using Arduino, using components like an HC-SR04 Ultrasonic Sensor, Servo Motor, LED Indicator, Buzzer, and a Push Button.
The system detects a hand placed near the sensor and activates a servo motor to dispense sanitizer—completely automatic, hygienic, and safe. This project is ideal for students, hobbyists, and professionals working in Product Design and Development, IoT, and Smart Device Engineering.

Components Used in Smart Sanitizer Dispenser Device
1. Arduino (UNO/Nano)
- Acts as the brain of the system
- Reads data from the ultrasonic sensor
- Controls the servo motor, LED, and buzzer
2. Ultrasonic Sensor (HC-SR04)
- Detects the presence of a hand
- Measures distance using ultrasonic waves
- Activates sanitizer dispensing when a hand is within 10–15 cm range
3. Servo Motor
- Mechanically pushes sanitizer pump
- Moves between 0° and 150° depending on detection
4. LED Indicator
- Turns ON when dispensing sanitizer
- Useful for status indication
5. Buzzer
- Gives a short beep when sanitizer is dispensed
- Helps in user feedback
6. Push Button
- Manual override to dispense sanitizer
- Useful for refilling or testing
Functionality of Smart Sanitizer Dispenser Device
1. Hand Detection Mode (Automatic Mode)
- The HC-SR04 Ultrasonic Sensor continuously measures distance.
- If a hand is detected between 6 cm and 15 cm, the system triggers:
- Servo Motor rotates from 0° to 150° to push the sanitizer pump
- LED turns ON
- Buzzer gives a short alert tone
- After dispensing, the system resets:
- Servo returns to 0°
- LED turns OFF
- Buzzer stops
This ensures fully touchless and hygienic dispensing.
2. Manual Mode (Button Press)
Your code also includes a push button:
- When button is pressed, the servo activates even without a hand detected
- Useful during:
- Refilling sanitizer
- Maintenance
- Manual dispensing as a backup
3. Safety Delay
- A built-in delay prevents continuous dispensing
- Ensures the motor and pump do not overwork
- Also helps in controlled sanitizer usage
Features of Smart Sanitizer Dispenser Device
- Fully touchless sanitizer dispensing
- Hygienic and safe design
- Uses Arduino Programming Language
- Ideal project for Smart Device Development
- Perfect for Product Design and Development of commercial solutions
- Low cost and highly reliable
- Easily expandable using IoT platforms (Blynk, ESP8266, NodeMCU, etc.)
Circuit Diagram of Smart Sanitizer Dispenser with Arduino

Arduino Code for Smart Sanitizer Dispenser
#include <Servo.h>
Servo myservo;
#define trigPin 13
#define echoPin 12
int ledpin = 7;
int buzzer = 6;
int button = 5;
long duration;
int distance;
unsigned long lastAction = 0;
void setup() {
Serial.begin(9600);
myservo.attach(9);
myservo.write(0);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledpin, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(button, INPUT);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
}
int getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
int d = duration * 0.034 / 2;
return d;
}
void dispense() {
Serial.println("Dispensing...");
myservo.write(90);
digitalWrite(ledpin, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
myservo.write(0);
digitalWrite(ledpin, LOW);
digitalWrite(buzzer, LOW);
delay(500);
}
void loop() {
int distance = getDistance();
int buttonState = digitalRead(button);
Serial.print("Distance: ");
Serial.println(distance);
if (distance < 20 && distance > 0) {
dispense();
}
if (buttonState == HIGH) {
dispense();
}
}
Applications of Smart Sanitizer Dispenser
- Offices, workplaces
- Schools and colleges
- Hospitals and clinics
- Restaurants, cafés
- Shops and malls
- Homes
Conclusion
The Smart Sanitizer Dispenser using Arduino is an excellent example of how electronics and automation can improve hygiene and everyday convenience. With the combination of Ultrasonic Sensor, Servo Motor, LED, Buzzer and Push Button, this smart device becomes both practical and reliable.
This project is also a great learning opportunity for enthusiasts and students in fields like Product Design and Development, Smart Electronics, and Arduino-based Automation Systems.
Need Help or Assistance in Smart Sanitizer Dispenser Project?
If you need this Smart Sanitizer Dispenser System Project with or without Modifications or Customization then you can contact us through WhatsApp.
if you can not make this project yourself then you can use this option. We will assemble the Project and will ship it to your Doorstep with Safe Packaging.
Learn More about the services we offer.