Project tutorial
Fun Coronavirus Kids Soap Clock

Fun Coronavirus Kids Soap Clock © GPL3+

Easy to make educational kids automatic detection "analog" clock for making hand washing as fun as possible

  • 997 views
  • 0 comments
  • 6 respects

Components and supplies

About this project

Say what? Fun educational Corona Clock!

While the WHO guidelines on hand hygiene suggest a 20 to 30 seconds of hand-washing with soap and water, when you have small children the question remains how you're getting them to do so...

Well this is the main educational purpose of this project, giving the kids a fun reason for a good long hand wash with automatic detection and a visual clock.

Now we can't stop them from washing hands all day long :)

Show me!

Here's some video of the clock (timing 20 sec with the detector on the right):

How it works

The project includes some cheap components with the Arduino Nano as the microcontroller:

The ultrasonic range sensor (top right) is used for sensing a "hand" at a defined distance, reaching for the soap. Better place it as we did in the side of the sink looking at the center or possibly from above if you can.

Moving the Clock's handle in a specific direction was done with a servo motor, with the tiny SG90 micro-servo (buttom right).

A speaker is useful for making some sounds, especially when testing the prototype and making sure things work. And then some batteries, preferably rechargeable 9V, jumper wires and a breadboard.

Creativity Time

First you need to make some picture for the clock. Well, my kids have gladly drawn one for it (lockdown time is creativty time).

This is the final result:

The clock's handle will be placed on the buttom in the center. It will take it 20 seconds to move from the left side (unwashed germ hands and sad soaps) to the right side (big like, rainbows and happy soaps heh heh).

Of course there is also the fun time of building the whole thing with the kids, learning how the sensors work, making sounds and moving the motor.

Working Prototype

Breadboard is always good for making a prototype, just to make sure things actually work and to play with the sensors and sounds. Cool, it really works!

The components are connected to the arduino controller as follows:

Ultrasonic sensor:

const byte pin_SensorTrig = 4; 
//pin attached to HC-SR04 distance sensor's input Trigger pin
const byte pin_SensorEcho = 5; 
//pin attached to the returning Echo pin from the sensor

Servo:

const byte servoPin = 10; 
//pin attached to SG90 9g micro servo Signal pin (Signal=orange,Vcc=red,Gnd=brown)

Speaker:

This simple 8 ohms speaker is connected to Arduino's pin 12. The speaker is off most of the time, but is still connected through a 100 ohms resistor to prevent over currenting the Arduino.

const byte pin_Speaker = 12; 
//pin attached to optional Speaker through 100 ohm resistor

Final circuit

The whole thing needs to get much smaller and maybe a little bit waterproof. This was done with a plastic box and precise wires.

Instead of the big breadboard you can use some small PCB, but I preffer the option of a tiny breadboard which does not require too much welding :)

Rechargeable 9V battery is attached to arduino's Vin pin which makes it quite compact, but any other power source would work just as well.

Enjoy, we did!!

Code

Fun Corona Soap Clock source codeC/C++
//FunCoronaSoapClock code for educational automatic handwash "analog" servo clock with sounds
//this is free software by ElectricAvi without any warranty feel free to modify for your own needs
#include <Servo.h>
const bool debug = false;

const byte pin_SensorTrig = 4; //pin attached to HC-SR04 distance sensor's input Trigger pin
const byte pin_SensorEcho = 5; //pin attached to the returning Echo pin from the sensor
const byte servoPin = 10; //pin attached to SG90 9g micro servo Signal pin (Signal=orange,Vcc=red,Gnd=brown)
const byte pin_Speaker = 12; //pin attached to optional Speaker through 100 ohm resistor
Servo myservo;  //create servo object to control a servo (one can be ran through arduino board Vcc)
float servoPos; //servo angle position 0-180 (Degrees)

float sensorDuration, sensorDistance; //distance sensor parameters
const float nearDistanceValue = 45; //define 45cm as a near sensor hand location
const int washingTime = 20; //total washing time (seconds)
const int servoStepDelay = 100; //"clock" tick time in ms

int StartingSound[] = {3500,5500,3500,5500}; byte StartingSounds = 4; //starting note frequencies at wash detection
int StartingSoundDelay = 70; //delay speed (ms) between each sound note
 
int GoodSound[] = {250,500,2000}; byte GoodSounds = 3; //sound note frequencies after "good" 20sec washing time
int GoodSoundDelay = 150;

void setup(){ 
  pinMode(pin_SensorTrig, OUTPUT); pinMode(pin_SensorEcho, INPUT); //set sensor i/o pins
  pinMode(pin_Speaker, OUTPUT); digitalWrite(pin_Speaker, LOW); //initialize speaker pin
  myservo.attach(servoPin); myservo.write(20); //set servo pin and move handle to final "Good" position
  if (debug) Serial.begin(9600);
}

void loop(){  
  //run several repetitive sensor measurements to find average distance
  float avgDistance = 0; 
  for (int i=0; i<15; i++) { 
    digitalWrite(pin_SensorTrig, LOW); delayMicroseconds(2); //send ultrasonic pulse
    digitalWrite(pin_SensorTrig, HIGH); delayMicroseconds(10);
    digitalWrite(pin_SensorTrig, LOW);  

    sensorDuration = pulseIn(pin_SensorEcho, HIGH); //measure sensor echo return time (us)    
    sensorDistance = (sensorDuration*.0343)/2; //calculate distance by speed of sound (0.0343 us/cm)

    avgDistance += sensorDistance; 
    delay(5);      
  }
  avgDistance /= 15; //calculate average sensor distance (cm) 

  if (debug) { 
    Serial.print("avgDistance="); Serial.println(avgDistance); 
  }
  
  //check if sensor detected a hand in front of it so soap-washing has began...
  if (avgDistance<nearDistanceValue) { 
    if (debug) Serial.println("Hand detected!!!");
              
    //play starting sound notes
    for (byte soundIdx=0; soundIdx<StartingSounds; soundIdx++) {    
      tone(pin_Speaker,StartingSound[soundIdx]); delay(StartingSoundDelay); noTone(pin_Speaker);
    }

    if (debug) Serial.println("sending servo to starting position");
    for (servoPos = 20; servoPos < 160; servoPos += 1) { //turn back servo handle to starting position
      myservo.write(servoPos);          
      delay(20);                              
    }

    if (debug) Serial.println("slowly turning the servo from initial Bad to final Good position");
    float servoStepDegrees = (160-20); //calculate degrees to rotate each tick
    servoStepDegrees = servoStepDegrees/(washingTime*1000)*servoStepDelay;
  
    //start slowly turning servo handle in the "good" direction at the right speed for total wash time
    for (servoPos = 160; servoPos >= 20; servoPos -= servoStepDegrees) { 
      myservo.write(servoPos);
      delay(servoStepDelay);              
    }

    //play good sound notes
    for (byte soundIdx=0; soundIdx<GoodSounds; soundIdx++) {    
      tone(pin_Speaker,GoodSound[soundIdx]); delay(GoodSoundDelay); noTone(pin_Speaker);
    }

    if (debug) Serial.println("played ending sound notes.");
    delay(2000); //delay a few seconds before checking sensor again    
  }
}

Schematics

Circuit schematic for the Corona Soap Clock
Coronasoapclockschematic 8ctqkvpkos

Comments

Similar projects you might like

Servo clock with digital display

Project tutorial by garysat

  • 1,691 views
  • 0 comments
  • 11 respects

DIY Gesture Controlled Talking Clock

Project tutorial by Mirko Pavleski

  • 1,321 views
  • 0 comments
  • 2 respects

Hand Washing Timer That Sings to You!

Project tutorial by goveil1

  • 410 views
  • 0 comments
  • 1 respect

Arduino Clock with Neopixel Ring Animation

Project tutorial by Alexander

  • 55,350 views
  • 44 comments
  • 82 respects

Making a Wooden LED Clock

Project tutorial by Andrew Jones

  • 39,965 views
  • 18 comments
  • 109 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 22,825 views
  • 24 comments
  • 79 respects
Add projectSign up / Login