
DIY Hand Wash Timer Using Arduino: A Simple Solution for Effective Hand Hygiene
Introduction
In the wake of increasing health concerns, such as the Covid-19 pandemic, hand hygiene has become more important than ever. The World Health Organization (WHO) recommends washing hands for 20-30 seconds with soap and water to effectively eliminate viruses and germs. However, it can sometimes be challenging to ensure that the proper amount of time is spent washing hands, especially for children. In this tutorial, we will show you how to design a Hand Wash Timer using Arduino, which will help track the time for hand washing and encourage proper hygiene.
Components Required for the Hand Wash Timer
Before we dive into the design, let’s go over the components you will need for the project:
Hardware Components:
- Arduino Uno or Arduino Nano
- Servo Motor
- Ultrasonic Sensor
- Buzzer
- Connecting Wires
- Power Supply
Working of the Hand Wash Timer

The primary goal of this project is to design a system that can track the time while washing hands, ensuring that it’s done for the recommended 20-30 seconds. The system will make it easier for children to wash their hands properly, as it provides a visual and auditory cue to encourage the right amount of hand-washing time.
When the user moves closer to the hand sanitizer (or automatic hand sanitizer dispenser), the ultrasonic sensor detects the motion and triggers the Arduino. Once the hand is within a specified distance, the timer activates, and the servo motor starts rotating. This rotation is mapped to represent the 30-second duration for hand washing (360 degrees rotation in 30 seconds).
Additionally, a buzzer will sound periodically during the washing process to indicate when time is up.
Setting Up the Hand Wash Timer

In this project, we are using the following components:
- Ultrasonic Sensor: To detect the presence of hands near the sanitizer dispenser.
- Servo Motor: This will act as the timer hand, showing how much time is left for washing.
- Buzzer: To alert the user when the time is up.

Let’s now look at the circuit diagrams for connecting the servo motor, ultrasonic sensor, and buzzer to the Arduino.

Circuit Diagram for Interfacing Components
- Servo Motor: Connect the servo’s signal pin to Arduino pin 9, the VCC pin to 5V, and the GND pin to ground.
- Ultrasonic Sensor: Connect the trigger pin to pin 3 and the echo pin to pin 2 of the Arduino.
- Buzzer: Connect one leg of the buzzer to pin 4 and the other to ground.
How the Hand Wash Timer Works
Once the components are connected and the system is powered on, the ultrasonic sensor detects when a hand is placed within range (usually 30 cm). When the sensor detects the hand, it sends a signal to the Arduino, which then activates the servo motor to start its rotation. The servo motor is set to rotate for 30 seconds, representing the proper amount of hand-washing time.
During this period, the buzzer will emit a sound to remind the user to keep washing their hands. Once the 30 seconds have passed, the servo motor will stop, and the buzzer will turn off.
Arduino Code for the Hand Wash Timer
Here’s the Arduino code that makes the Hand Wash Timer work:
cpp
CopyEdit
#include <Servo.h>
const int echoPin = 2; // Echo Pin of Ultrasonic Sensor
const int trigPin = 3; // Trigger Pin of Ultrasonic Sensor
int buzzer = 4; // Buzzer Pin
Servo myservo; // Create servo object
long duration;
int distance, count = 0;
void setup() {
myservo.attach(9); // Servo connected to pin 9
pinMode(trigPin, OUTPUT); // Trigger Pin as OUTPUT
pinMode(echoPin, INPUT); // Echo Pin as INPUT
pinMode(buzzer, OUTPUT); // Buzzer Pin as OUTPUT
Serial.begin(9600); // Start Serial Communication
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print(“Distance: “);
Serial.println(distance);
if (distance < 30) { // Check if the hand is within the desired range
count++;
if (count < 21) {
digitalWrite(buzzer, HIGH); // Turn on the buzzer
int servo_angle = map(count, 0, 1023, 0, 180); // Map count to servo angle
myservo.write(servo_angle); // Move the servo
delay(1000); // Wait for 1 second
digitalWrite(buzzer, LOW); // Turn off the buzzer
} else {
digitalWrite(buzzer, LOW); // Turn off the buzzer
count = 0; // Reset the count
}
}
}
Conclusion

With this simple DIY Hand Wash Timer, you can ensure that your family members, especially children, wash their hands for the recommended 20-30 seconds, which helps prevent the spread of germs and viruses. The project is easy to assemble and can be a fun and educational way to promote hygiene at home.
If you’re looking for quality components to build your own hand wash timer, Regent Electronics offers a wide range of products including Arduino boards, sensors, servos, and more. Visit Regent Electronics today and get everything you need to create your own hand wash timer or any other exciting DIY projects!