Projects / 20-second hand wash timer

20-second hand wash timer

Beginner1 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Mount the sensor

    Fix the IR sensor by the tap so a hand under the tap is 5 to 10 cm from it.

  2. NANO

    Wire the sensor

    VCC to 5V, GND to GND, OUT to D2. Turn its trimmer until the LED lights only for a hand.

  3. NANO19.3 mA

    Wire the ring

    DIN through 330 Ω to D6, 5V and GND with a 100 µF capacitor across them.

  4. NANO

    Add the buzzer

    Positive to D8, negative to GND.

  5. NANO

    Upload

    Install the NeoPixel library and upload.

  6. NANO19.3 mA

    Try it

    Put a hand in front. The blue ring should count down over 20 seconds, then play a tune and flash green.

In short

How do you build a 20-second hand wash timer?

An IR sensor by the sink starts a 20-second LED ring countdown when hands come near, and plays a happy tune at the end. You need Arduino Nano, IR obstacle avoidance sensor module, WS2812B ring 16 LEDs, Passive buzzer, Resistor 330 Ω, Electrolytic Capacitor 100 µF, 5 V 2 A USB adapter and USB A to micro-USB cable (data). It takes 6 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
IR sensor VCC / GNDNano 5V / GNDSensor power
IR sensor OUTNano D2LOW when something is close
Ring DIN330 Ω then Nano D6LED data
Ring 5V / GNDNano 5V / GND, with a 100 µF capacitor across themPower for 16 LEDs
Passive buzzer + / −Nano D8 / GNDEnd tune

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "Adafruit NeoPixel" from the Library Manager. Washes are counted in EEPROM address 0 and can be read by adding Serial.println(washes).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>

Adafruit_NeoPixel ring(16, 6, NEO_GRB + NEO_KHZ800);
const byte SENSOR = 2, BUZ = 8;
const unsigned long WASH_MS = 20000;
unsigned int washes;

void setup() {
  pinMode(SENSOR, INPUT);
  ring.begin(); ring.setBrightness(40); ring.clear(); ring.show();
  EEPROM.get(0, washes);
  if (washes == 0xFFFF) washes = 0;      // blank EEPROM
}

bool hands() { return digitalRead(SENSOR) == LOW; }

void loop() {
  if (!hands()) return;
  unsigned long t0 = millis(), lastSeen = t0;
  while (millis() - t0 < WASH_MS) {
    if (hands()) lastSeen = millis();
    if (millis() - lastSeen > 3000) { ring.clear(); ring.show(); return; }   // hands left, cancel
    byte lit = 16 - (millis() - t0) * 16 / WASH_MS;                          // LEDs left
    for (byte i = 0; i < 16; i++)
      ring.setPixelColor(i, i < lit ? ring.Color(0, 120, 255) : 0);
    ring.show();
  }
  int notes[] = {523, 659, 784, 1047};
  for (int n : notes) { tone(BUZ, n, 150); delay(180); }
  for (byte i = 0; i < 16; i++) ring.setPixelColor(i, ring.Color(0, 255, 0));
  ring.show();
  washes++; EEPROM.put(0, washes);
  delay(2000);
  ring.clear(); ring.show();
  while (hands()) {}
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Hand in front for 20 sRing counts down, tune plays, ring flashes green
Hand removed after 5 sTimer cancels after 3 s and the ring turns off
No handRing stays off
Wash counterIncreases by one after each full wash

If it does not work

The ring starts without a hand

Turn the IR trimmer so the sensor LED is off when nothing is near, and keep sunlight off it.

The ring flickers

Add the 100 µF capacitor and use a solid ground wire.

Only some LEDs light

Check ring orientation: DIN is the input pad.

No tune

Use a passive buzzer, not an active one, and check D8.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the 20-second hand wash timer?

Arduino Nano, IR obstacle avoidance sensor module, WS2812B ring 16 LEDs, Passive buzzer, Resistor 330 Ω, Electrolytic Capacitor 100 µF, 5 V 2 A USB adapter and USB A to micro-USB cable (data).

How long does the 20-second hand wash timer take to build?

About 60 minutes for a beginner maker, in 6 steps.

How do I know the 20-second hand wash timer works?

Hand in front for 20 s: Ring counts down, tune plays, ring flashes green. Hand removed after 5 s: Timer cancels after 3 s and the ring turns off. No hand: Ring stays off.

The ring starts without a hand: what should I check?

Turn the IR trimmer so the sensor LED is off when nothing is near, and keep sunlight off it.

The ring flickers: what should I check?

Add the 100 µF capacitor and use a solid ground wire.

Only some LEDs light: what should I check?

Check ring orientation: DIN is the input pad.

No tune: what should I check?

Use a passive buzzer, not an active one, and check D8.