1. Introduction
Automatic hand sanitizers are widely used in hospitals, schools, offices, and public places to maintain hygiene and prevent the spread of germs. A touchless sanitizer system reduces physical contact and makes the sanitizing process safer and more convenient.
In this project, we build an IR Based Automatic Hand Sanitizer using an Arduino Uno R3. The system uses an Infrared Sensor Module to detect the presence of a hand. When a hand is placed near the sensor, the Arduino activates a servo motor which presses the sanitizer bottle pump and dispenses sanitizer automatically.
This is a simple and practical Arduino project that helps beginners learn about sensors, automation, and servo motor control.
2. Components
| Sl No | Component | Quantity |
|---|---|---|
| 1 | Arduino Uno R3 | 1 |
| 2 | Infrared Obstacle Avoidance Sensor Module | 1 |
| 3 | Servo Motor (SG90) | 1 |
| 4 | Sanitizer Bottle | 1 |
| 5 | Breadboard | 1 |
| 6 | Jumper Wires | As required |
| 7 | USB Cable for Arduino | 1 |
3. Circuit and Connections
IR Sensor Connections
VCC → 5V (Arduino)
GND → GND (Arduino)
OUT → Digital Pin 7
Servo Motor Connections
Red → 5V
Brown/Black → GND
Orange/Yellow → Digital Pin 9
The IR sensor detects the hand and sends a signal to the Arduino. The Arduino then controls the servo motor to press the sanitizer pump.
4. Circuit Working
The working of the IR Based Automatic Hand Sanitizer is simple and efficient.
-
The IR sensor continuously emits infrared light.
-
When a hand is placed near the sensor, the light reflects back to the receiver.
-
The sensor detects the reflection and sends a digital signal to the Arduino.
-
The Arduino reads the signal from the sensor.
-
If an object (hand) is detected, the Arduino rotates the servo motor.
-
The servo motor presses the sanitizer pump and releases sanitizer.
-
After a short delay, the servo motor returns to its original position.
This creates a touch-free sanitizer dispensing system.
5. Code
#include <Servo.h>
Servo sanitizerServo;
int sensorPin = 7;
int servoPin = 9;
void setup()
{
pinMode(sensorPin, INPUT);
sanitizerServo.attach(servoPin);
sanitizerServo.write(0);
}
void loop()
{
int sensorState = digitalRead(sensorPin);
if(sensorState == LOW)
{
sanitizerServo.write(90);
delay(1000);
sanitizerServo.write(0);
delay(2000);
}
}
6. Code Working
First, the Servo library is included to control the servo motor. A servo object named sanitizerServo is created.
In the setup() function, the IR sensor pin is configured as an input and the servo motor is attached to digital pin 9. The servo is initially set to position 0 degrees.
Inside the loop() function, Arduino continuously reads the IR sensor output using digitalRead().
When the sensor detects a hand, it sends a LOW signal. The Arduino then rotates the servo motor to 90 degrees, which presses the sanitizer bottle pump.
After a short delay, the servo motor returns to its original position, ready for the next use.
7. Tips
-
Adjust the IR sensor potentiometer to set the detection distance.
-
Use a stable 5V power supply for the servo motor.
-
Make sure the servo arm is properly aligned with the sanitizer pump.
-
Avoid placing the sensor in direct sunlight, as it may affect detection.
8. Uses
This automatic sanitizer system can be used in many places such as:
-
Hospitals
-
Schools and colleges
-
Offices
-
Laboratories
-
Public entrances
-
Homes
9. Conclusion
In this project, we built a DIY IR Based Automatic Hand Sanitizer using Arduino. The system uses an IR sensor to detect a hand and automatically activates a servo motor to dispense sanitizer.
This project demonstrates a simple automation system using Arduino and sensors. It is an excellent beginner project for learning sensor interfacing, servo motor control, and practical electronics applications.
