Touchless Washing Hands Timer
by rjconcepcion in Circuits > Arduino
412 Views, 1 Favorites, 0 Comments
Touchless Washing Hands Timer


I have created this project to count the minimum time recommended by the health authorities that we should wash our hands.
This project works in the following way:
You should close your hand at least 5 cm to the sensor. The device makes a sound and starts the count. After 20 seconds, the device makes 3 sounds and wait for the activation again.
Supplies
- Arduino Uno. https://amzn.to/3aLoF4C
- Ultrasonic sensor HC-SR04. https://amzn.to/2x2iR84
- Shift register SN74HC595. https://amzn.to/2ULJuHI
- 2 und 7 segment display. https://amzn.to/2yvydlW
- 2 und Transistor 2N3904. https://amzn.to/2xSJuwA
- Buzzer. https://amzn.to/34crw3U
- 2 und Resistors 330 Ohm. https://amzn.to/2V32Maj
- 2 und Resistors 1000 Ohm.
- Resistor 220 Ohm.
Make the Connections


Make the connections shown in the schematic.
Upload the Code to the Arduino
// Touchless washing hands timer
// Info library NewPing https://playground.arduino.cc/Code/NewPing/
#include // Library for sensor HC-SR04
const int trigger = 2; // D2 trigger Pin
const int echo = 3; // D3 echo Pin
const int max_dist = 200; // max distance 200 cm
const int led = 13; // Build-in led
const int sonido = 12; // Buzzer pin
//D9 to pin 12 latch (RCLK) 74HC595
const int latchPin = 9;
//D10 to Pin 11 Clock (SRCLK) 74HC595
const int clockPin = 10;
//D8 to Pin 14 Data (SER) 74HC595
const int dataPin = 8;
const int tdigt1 = 4; // Transistor digit 1
const int tdigt2 = 5; // Transistor digit 2
//7Segment display configuration
const byte CHAR_COUNT = 11;
const byte symbols[CHAR_COUNT] = {
//GFEDCBAd
B01111110, // 0
B00001100, // 1
B10110110, // 2
B10011110, // 3
B11001100, // 4
B11011010, // 5
B11111010, // 6
B00001110, // 7
B11111110, // 8
B11011110, // 9
B10000000, // -
};
int dist = 0; // Distance variable
int var = 20; // Time varible. You can change this value.
int digt1 = 0; // Var digit 1
int digt2 = 0; // Var digit 2
NewPing sonar(trigger, echo, max_dist); // NewPing constructor
void setup() {
Serial.begin(9600); // Set serial communication speed
pinMode(led, OUTPUT); // Led pin as output
pinMode(sonido, OUTPUT); // Sound pin as output
pinMode(latchPin, OUTPUT); // lachtPin as output
pinMode(dataPin, OUTPUT); // dataPin as output
pinMode(clockPin, OUTPUT); // clockPin as output
pinMode(tdigt1, OUTPUT); // tdigit1 as output
pinMode(tdigt2, OUTPUT); // tdigit2 as output
}
void loop() {
delay(50);
dist = sonar.ping_cm(); // Get the distance.
Serial.print(dist); // Print distance in serial monitor.
Serial.println("cm");
delay(500);
// Start this cycle if the distance is less than 5 cm
if ((dist <= 5) & (dist > 0)) {
digitalWrite(led, HIGH);
beep(200); // Make a sound
while (var > 0){ // While cycle for counter
digt1 = var % 10; // Get the remainder
digt2 = var / 10; // Get first digit
for (int i=0; i<50; i++) { // Show every digit 10 ms.
digitalWrite(tdigt1, HIGH);
writeLeds(symbols[digt1]); // Write symbols in the displays.
delay(10);
digitalWrite(tdigt1, LOW);
digitalWrite(tdigt2, HIGH);
writeLeds(symbols[digt2]);
delay(10);
digitalWrite(tdigt2, LOW);
}
var--;
}
var = 20;
beep(200);
beep(200);
beep(200);
} //If the sensor is not active.
else {
digitalWrite(led, LOW);
digitalWrite(tdigt1, HIGH);
writeLeds(symbols[10]);
digitalWrite(tdigt2, HIGH);
writeLeds(symbols[10]);
}
}
// beep function.
void beep(unsigned char delayms){
analogWrite(sonido, 200);
delay(delayms);
analogWrite(sonido, 0);
delay(delayms);
}
//writeleds function. Info https://www.arduino.cc/reference/en/language/func...
void writeLeds(byte pattern) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, pattern);
digitalWrite(latchPin, HIGH);
}
Test It and Wash Your Hands.
