GadhaGod
Published

Simple Hand Wash Timer

This will make sure you wash your hands for thirty seconds.

IntermediateFull instructions provided1,914
Simple Hand Wash Timer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Grove - 16 x 2 LCD (Black on Red)
Seeed Studio Grove - 16 x 2 LCD (Black on Red)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Buzzer
Buzzer
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

connections_hand_wash_timer_IticckVuxG.png

Hand Wash Timer Circuit

Code

Hand Wash Timer

C/C++
/*
 *   DISTANCE SENSOR:
        VCC: 5V
        Trigger to Pin 8
        Echo to Pin 9
        GND to GND

      The LCD:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to 5V and ground
 * wiper to LCD VO pin (pin 3)    
 * 
 * 
 *    The buzzer:
 * posotive leg to pin 7
 * negaitive leg to gnd
 */
 
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int buzzerPin = 7;
int trigPin = 8;    
int echoPin = 9;    
int 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. 
 
void setup() {
  //begin serial monitor
  Serial.begin (9600);
  //specify inputs and outputs
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  //The LCD has 16 columns and two rows
  lcd.begin(16, 2);
  // Start writing at this point
  lcd.setCursor(0, 2);
}
 
void loop() {
  //clear the LCD
  lcd.clear();
  // Print to the LCD
  lcd.print("Hand wash timer");
  // Use the distance sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  int distance = pulseIn(echoPin, HIGH);
  // Print to the Serial Monitor (optional)
  Serial.println(distance);


  // if the nearest object is less then 2000 units away...
  if (distance < handDistance){
    //sounds buzzer
  tone(buzzerPin, 1000, 1000);
  // repeats the code that tells how many seconds are left for thrity seconds
    for (int i = 30; i  > 0; --i){
      lcd.setCursor(0, 1);
      lcd.print(i);
      delay(1000);
      lcd.setCursor(0, 1);
      lcd.print("  ");
    }
    //sounds the buzzer after the thirty seconds are up
    tone(buzzerPin, 1000, 2500);
    
  }

  delay(500);
  
  

}

Credits

GadhaGod

GadhaGod

17 projects • 20 followers

Comments