Simple Hand Wash Timer
This will make sure you wash your hands for thirty seconds.
Devices & Components
1
Arduino Uno Rev3
1
Jumper wires (generic)
1
Ultrasonic Sensor - HC-SR04 (Generic)
1
Rotary potentiometer (generic)
1
Resistor 220 ohm
1
Buzzer
1
Grove - 16 x 2 LCD (Black on Red)
Software & Tools
Arduino IDE
Project description
Code
Hand Wash Timer
c_cpp
1/* 2 * DISTANCE SENSOR: 3 VCC: 5V 4 Trigger to Pin 8 5 Echo to Pin 9 6 GND to GND 7 8 The LCD: 9 * LCD RS pin to digital pin 12 10 * LCD Enable pin to digital pin 11 11 * LCD D4 pin to digital pin 5 12 * LCD D5 pin to digital pin 4 13 * LCD D6 pin to digital pin 3 14 * LCD D7 pin to digital pin 2 15 * LCD R/W pin to ground 16 * LCD VSS pin to ground 17 * LCD VCC pin to 5V 18 * 10K resistor: 19 * ends to 5V and ground 20 * wiper to LCD VO pin (pin 3) 21 * 22 * 23 * The buzzer: 24 * posotive leg to pin 7 25 * negaitive leg to gnd 26 */ 27 28#include <LiquidCrystal.h> 29LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 30 31int buzzerPin = 7; 32int trigPin = 8; 33int echoPin = 9; 34int handDistance = 2000; //this will vary depending on how big your sink is. If the closest object is less than handDistance, then the countdown starts. Use the serial monitor to determine what it's value shoud be. 35 36void setup() { 37 //begin serial monitor 38 Serial.begin (9600); 39 //specify inputs and outputs 40 pinMode(trigPin, OUTPUT); 41 pinMode(echoPin, INPUT); 42 //The LCD has 16 columns and two rows 43 lcd.begin(16, 2); 44 // Start writing at this point 45 lcd.setCursor(0, 2); 46} 47 48void loop() { 49 //clear the LCD 50 lcd.clear(); 51 // Print to the LCD 52 lcd.print("Hand wash timer"); 53 // Use the distance sensor 54 digitalWrite(trigPin, LOW); 55 delayMicroseconds(5); 56 digitalWrite(trigPin, HIGH); 57 delayMicroseconds(10); 58 digitalWrite(trigPin, LOW); 59 int distance = pulseIn(echoPin, HIGH); 60 // Print to the Serial Monitor (optional) 61 Serial.println(distance); 62 63 64 // if the nearest object is less then 2000 units away... 65 if (distance < handDistance){ 66 //sounds buzzer 67 tone(buzzerPin, 1000, 1000); 68 // repeats the code that tells how many seconds are left for thrity seconds 69 for (int i = 30; i > 0; --i){ 70 lcd.setCursor(0, 1); 71 lcd.print(i); 72 delay(1000); 73 lcd.setCursor(0, 1); 74 lcd.print(" "); 75 } 76 //sounds the buzzer after the thirty seconds are up 77 tone(buzzerPin, 1000, 2500); 78 79 } 80 81 delay(500); 82 83 84 85}
Hand Wash Timer
c_cpp
1/* 2 * DISTANCE SENSOR: 3 VCC: 5V 4 Trigger to Pin 8 5 Echo to Pin 9 6 GND to GND 7 8 The LCD: 9 * LCD RS pin to digital pin 12 10 * LCD Enable pin to digital pin 11 11 * LCD D4 pin to digital pin 5 12 * LCD D5 pin to digital pin 4 13 * LCD D6 pin to digital pin 3 14 * LCD D7 pin to digital pin 2 15 * LCD R/W pin to ground 16 * LCD VSS pin to ground 17 * LCD VCC pin to 5V 18 * 10K resistor: 19 * ends to 5V and ground 20 * wiper to LCD VO pin (pin 3) 21 * 22 * 23 * The buzzer: 24 * posotive leg to pin 7 25 * negaitive leg to gnd 26 */ 27 28#include <LiquidCrystal.h> 29LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 30 31int buzzerPin = 7; 32int trigPin = 8; 33int echoPin = 9; 34int handDistance = 2000; //this will vary depending on how big your sink is. If the closest object is less than handDistance, then the countdown starts. Use the serial monitor to determine what it's value shoud be. 35 36void setup() { 37 //begin serial monitor 38 Serial.begin (9600); 39 //specify inputs and outputs 40 pinMode(trigPin, OUTPUT); 41 pinMode(echoPin, INPUT); 42 //The LCD has 16 columns and two rows 43 lcd.begin(16, 2); 44 // Start writing at this point 45 lcd.setCursor(0, 2); 46} 47 48void loop() { 49 //clear the LCD 50 lcd.clear(); 51 // Print to the LCD 52 lcd.print("Hand wash timer"); 53 // Use the distance sensor 54 digitalWrite(trigPin, LOW); 55 delayMicroseconds(5); 56 digitalWrite(trigPin, HIGH); 57 delayMicroseconds(10); 58 digitalWrite(trigPin, LOW); 59 int distance = pulseIn(echoPin, HIGH); 60 // Print to the Serial Monitor (optional) 61 Serial.println(distance); 62 63 64 // if the nearest object is less then 2000 units away... 65 if (distance < handDistance){ 66 //sounds buzzer 67 tone(buzzerPin, 1000, 1000); 68 // repeats the code that tells how many seconds are left for thrity seconds 69 for (int i = 30; i > 0; --i){ 70 lcd.setCursor(0, 1); 71 lcd.print(i); 72 delay(1000); 73 lcd.setCursor(0, 1); 74 lcd.print(" "); 75 } 76 //sounds the buzzer after the thirty seconds are up 77 tone(buzzerPin, 1000, 2500); 78 79 } 80 81 delay(500); 82 83 84 85}
Downloadable files
Hand Wash Timer Circuit
Hand Wash Timer Circuit

Hand Wash Timer Circuit
Hand Wash Timer Circuit

connections_hand_wash_timer_IticckVuxG.png
connections_hand_wash_timer_IticckVuxG.png

Comments
Only logged in users can leave comments