Project showcase
The Hooray Machine

The Hooray Machine © CC BY

Trying to find a way to surprise your friend on their birthday? Searching for a creative way to celebrate Christmas? Look no further!

  • 915 views
  • 1 comment
  • 5 respects

Components and supplies

About this project

The Hooray Machine

I created the “Hooray” machine because I wanted to surprise my friends whenever it was their birthday or Christmas. Originally, I was going to make it a laser tripwire birthday surprise, but I didn’t have enough room to add a laser. Then I thought how fun it would be to simply click a button, and play a song, with a flashing lightbulb. I even added an LCD screen to add onto the fun. That was when the “Hooray” machine came to mind. It’s a machine that plays both “Happy Birthday” and “We Wish You a Merry Christmas” at the click of a button. An LCD screen shows the words of the song as it plays and an RGB LED flashes different colors synchronized to the song. The song is played by a piezo buzzer.

Code

CodeArduino
This is the code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int btn;
int btn2;
int d4 = 294;
int e4 = 330;
int g4 = 392;
int gflat4 = 370;
int a4 = 440;
int d5 = 587;
int b4 = 494;
int c5 = 523;
int g5 = 784;
int e5 = 659;
int f5 = 698;

void setup()
{
  lcd.begin(16, 2);

  lcd.clear();
  
  lcd.print("Hello World");
  delay(1000);
  lcd.clear();
  delay(500);
  pinMode(6, OUTPUT); //Blue
  pinMode(9, OUTPUT); //Green
  pinMode(10, OUTPUT); //Red
  pinMode(8, INPUT); //button 1
  pinMode(13, INPUT); //button 2
  pinMode(7, OUTPUT); //piezo

  analogWrite(6, 0);
  analogWrite(9, 0);
  analogWrite(10, 0);
  lcd.print("Button 1");
  delay(2000);
  lcd.clear();
  delay(500);
  lcd.print("Birthday");
  delay(2000);
  lcd.clear();
  delay(1000);
  lcd.print("Button 2");
  delay(2000);
  lcd.clear();
  delay(500);
  lcd.print("Christmas");
  delay(2000);
  lcd.clear();
  delay(1000);
  
  
}


void loop()
{
 
  btn2 = digitalRead(13);
  if(btn2 == LOW)
  {
    lcd.print("Happy Birthday");
    delay(1000);
    lcd.clear();
    lcd.print("Expect...");
    delay(1000);
    lcd.clear();
    lcd.print("The Unexpected");
    delay(2000);
    lcd.clear();
    lcd.print("Happy");
    tone(7, d4);
    analogWrite(10, 255);
    delay(250); //eigth note
    noTone(7);
    analogWrite(10, 0);
    delay(100);
    tone(7, d4); 
    analogWrite(10, 255);
    delay(125);
    lcd.clear();
    lcd.print("Birth");
    tone(7, e4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    lcd.print("day");
    tone(7, d4);
    analogWrite(9, 0);
    analogWrite(6, 255);
    delay(500);
    lcd.clear();
    lcd.print("To");
    tone(7, g4);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print(" you!");
    tone(7, gflat4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(1000);
    noTone(7);
    lcd.clear();
    delay(500);
    analogWrite(9, 0);
    lcd.clear();
    lcd.print("Happy");
    tone(7, d4);
    analogWrite(6, 255);
    delay(250); //eigth note
    noTone(7);
    analogWrite(6, 0);
    delay(100);
    tone(7, d4); 
    analogWrite(10, 255);
    delay(125);
    lcd.clear();
    lcd.print("Birth");
    tone(7, e4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    lcd.print("day");
    tone(7, d4);
    analogWrite(9, 0);
    analogWrite(6, 255);
    delay(500);
    lcd.clear();
    lcd.print("To");
    tone(7, a4);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print(" you!");
    tone(7, g4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(1000);
    noTone(7);
    lcd.clear();
    analogWrite(9, 0);
    delay(500);
    lcd.print("Happy");
    tone(7, d4);
    analogWrite(6, 255);
    delay(250); //eigth note
    noTone(7);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(100);
    tone(7, d4); 
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(125);
    lcd.clear();
    tone(7, d5);
    analogWrite(9, 0);
    analogWrite(6, 255);
    lcd.print("Birth");
    delay(500);
    lcd.print("day");
    tone(7, b4);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.clear();
    lcd.print("Dear");
    tone(7, g4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    noTone(7);
    analogWrite(9, 0);
    delay(100);
    lcd.print(" Some");
    tone(7, g4);
    analogWrite(6, 255);
    delay(500);
    lcd.print("one");
    tone(7, gflat4);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(1000);
    lcd.clear();
    noTone(7);
    analogWrite(10, 0);
    delay(500);
    lcd.print("Happy");
    tone(7, c5);
    analogWrite(9, 255);
    delay(500);
    noTone(7);
    analogWrite(9, 0);
    delay(100);
    tone(7, c5);
    analogWrite(6, 255);
    delay(250);
    lcd.clear();
    lcd.print("Birth");
    tone(7, b4);
    analogWrite(6, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print("day");
    tone(7, g4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(1000);
    lcd.clear();
    lcd.print("To");
    tone(7, a4);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print(".");
    delay(500);
    lcd.print(".");
    delay(500);
    lcd.print(".");
    delay(500);
    tone(7, g5);
    lcd.print(" YOU!");
    analogWrite(10, 0);
    analogWrite(6, 255);
    delay(250);
    noTone(7);
    analogWrite(6, 0);
    lcd.clear();
  }
  
  btn = digitalRead(8);
  if(btn == LOW)
  {
    lcd.print("Merry Christmas!");
    delay(1000);
    lcd.clear();
    lcd.print("We");
    tone(7, g4);
    analogWrite(9, 255);
    delay(500);
    lcd.print(" wish");
    tone(7, c5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(500);
    noTone(7);
    analogWrite(10, 0);
    delay(50);
    lcd.print(" you");
    tone(7, c5);
    analogWrite(9, 255);
    delay(250);
    lcd.clear();
    lcd.print("A");
    tone(7, d5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    lcd.print(" Mer");
    tone(7, c5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    lcd.print("ry");
    tone(7, b4);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    lcd.clear();
    lcd.print("Christ");
    tone(7, a4);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    noTone(7);
    analogWrite(9, 0);
    delay(250);
    tone(7, a4);
    analogWrite(10, 255);
    lcd.print("mas");
    delay(250);
    noTone(7);
    analogWrite(10, 0);
    delay(250);
    lcd.clear();
    lcd.print("We");
    tone(7, a4);
    analogWrite(9, 255); 
    delay(500);
    lcd.print(" wish");
    tone(7, d5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(500);
    noTone(7);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(50);
    lcd.print(" you");
    tone(7, d5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    lcd.clear();
    lcd.print("A");
    tone(7, e5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    lcd.print(" Mer");
    tone(7, d5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    lcd.print("ry");
    tone(7, c5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    lcd.clear();
    lcd.print("Christ");
    tone(7, b4);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    noTone(7);
    analogWrite(10, 0);
    delay(250);
    tone(7, g4);
    analogWrite(9, 255);
    lcd.print("mas");
    delay(250);
    noTone(7);
    analogWrite(9, 0);
    delay(250);
    lcd.clear();
    lcd.print("We");
    tone(7, b4);
    analogWrite(10, 255);
    delay(500);
    lcd.print(" wish");
    tone(7, e5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    noTone(7);
    analogWrite(9, 0);
    delay(50);
    lcd.print(" you");
    tone(7, e5);
    analogWrite(10, 255);
    delay(250);
    lcd.clear();
    lcd.print("A");
    tone(7, f5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    lcd.print(" Mer");
    tone(7, e5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    lcd.print("ry");
    tone(7, d5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(250);
    lcd.clear();
    lcd.print("Christ");
    tone(7, c5);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(250);
    noTone(7);
    analogWrite(10, 0);
    delay(250);
    tone(7, a4);
    analogWrite(9, 255);
    lcd.print("mas");
    delay(250);
    noTone(7);
    analogWrite(9, 0);
    delay(250);
    lcd.clear();
    lcd.print("And");
    tone(7, g4);
    analogWrite(10, 255);
    delay(250);
    noTone(7);
    analogWrite(10, 0);
    delay(50);
    lcd.print(" a");
    tone(7, g4);
    analogWrite(9, 255);
    delay(250);
    lcd.clear();
    lcd.print("Hap");
    tone(7, a4);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print("py");
    tone(7, d5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    lcd.clear();
    lcd.print("New");
    tone(7, b4);
    analogWrite(9, 0);
    analogWrite(10, 255);
    delay(500);
    lcd.print(" Year");
    tone(7, c5);
    analogWrite(10, 0);
    analogWrite(9, 255);
    delay(500);
    noTone(7);
    analogWrite(9, 0);
    lcd.clear();
  }
}

Schematics

Wiring diagram
I created this diagram to show how I made this project
Real electronics final project g722nedc8a

Comments

Similar projects you might like

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 1,081 views
  • 5 comments
  • 14 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 80,377 views
  • 61 comments
  • 160 respects

Arduino Morse Code Machine

Project showcase by Vlada Krsmanovic

  • 10,221 views
  • 1 comment
  • 30 respects

Beepee Boopee Buzz Buzz

Project showcase by MarcusDeLUCa

  • 892 views
  • 3 comments
  • 3 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,293 views
  • 115 comments
  • 185 respects

Rickroll Box

Project showcase by slagestee

  • 4,937 views
  • 0 comments
  • 14 respects
Add projectSign up / Login