cubercraft24
Published

Touchless 20 second musical handwashing timer

This is a Arduino made project that plays the song Staying Alive as a timer for kids who struggle to wash there hands for 20 seconds.

IntermediateFull instructions provided812
Touchless 20 second musical handwashing timer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Computer

Story

Read more

Schematics

set_up_leKgCa1WG5.PNG

Code

Untitled file

Arduino
#define trigPin 13

#define echoPin 12

#define led 10

void setup() { 
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(led, OUTPUT);
}

void loop(){ 
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  if (distance < 10){
    Countdown();
    Wait();
    Song();      
    
  }
  else {
  Wait();
  }
  Serial.print(distance);

  Serial.println(" cm");

  delay(125);

} 

void playSound() {
    digitalWrite(led,HIGH);
    delay(100);
    digitalWrite(led,LOW);
    delay(100);
 
}

void Countdown() {
   tone(10, 2000, 100);
  delay(900);
   tone(10, 2000, 100);
  delay(900);
   tone(10, 2000, 100);
  delay(900);
   tone(10, 3000, 1000);
  delay(125);
}

void Wait() {
delay(100);
}


void Song() {
  //Verse
  tone(10, 523.25, 100);
  delay(150);
  tone(10, 523.25, 100);
  delay(150);
  tone(10, 523.25, 100);
  delay(150);
  tone(10, 523.25, 100);
  delay(150);
  tone(10, 466.61, 100);
  delay(150);
  tone(10, 466.61, 100);
  delay(150);
  tone(10, 466.61, 100);
  delay(150);
  tone(10, 466.61, 100);
  delay(150);
  tone(10, 415.3, 100);
  delay(150);
  tone(10, 415.3, 100);
  delay(150);
  tone(10, 415.3, 100);
  delay(150);
  tone(10, 415.3, 100);
  delay(150);
  tone(10, 392, 100);
  delay(150);
   tone(10, 392, 100);
  delay(150);
   tone(10, 392, 100);
  delay(150);
   tone(10, 392, 100);
  delay(150);
   tone(10, 311.13, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(700);
   tone(10, 311.13, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(700);
//Chorus
   tone(10, 523.25, 200);
  delay(700);
   tone(10, 466.16, 200);
  delay(700);
   tone(10, 415.3, 200);
  delay(700);
   tone(10, 392, 200);
 delay(700);

 tone(10, 311.13, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(700);
   tone(10, 311.13, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 150);
  delay(700);

   tone(10, 523.25, 200);
  delay(700);
   tone(10, 466.16, 200);
  delay(700);
   tone(10, 415.3, 200);
  delay(700);
   tone(10, 392, 200);

   delay(700);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
  delay(150);
   tone(10, 349.23, 100);
   delay(150);
  
 
   tone(10, 523.25, 2000);
 delay(2000);
   tone(10, 466.16, 2000);
   delay(2000);
   tone(10, 415.30, 2000);
 delay(2000);
   tone(10, 392, 2000);
  delay(2000);
}

Credits

cubercraft24
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.