/* Wash Hands Timer Written June 14, 2020 by R Jordan Keindler Uses an I2C 1602, An IR Obstacle Avoidance Module, and an Arduino UNO */ #include LiquidCrystal_I2C lcd(0x27, 16, 2); // Set I2C address to 0x27 int IRModulePinNumber = 7; int delay1 = 1000; int i; int val; void setup() { pinMode(IRModulePinNumber, INPUT); lcd.init(); // initialize the lcd Serial.begin(9600); } void loop() { val = digitalRead(IRModulePinNumber); // Read the IR Collision Avoidance OUT pin Serial.print(val); Serial.print("\n"); if (val == 0) // If a hand is near { lcd.backlight(); // Turn on the backlight lcd.clear(); // Clear the LCD and place cursor at first position on first line lcd.print("Wash Hands Timer"); // Print "Wash Hands Timer" on first line of LCD lcd.setCursor(0, 1); // Position display cursor on second line lcd.print("Elapsed time: "); // Print "Elapsed time: " on second line of LCD for (i = 1; i <= 60; i++) { // Count the seconds lcd.setCursor(14, 1); lcd.print(i); delay(delay1); } lcd.noBacklight(); // Turn backlight Off } }