Things used in this project

Schematics

Schematics with Fritzing
canzoni_con_tastiera_fQS3978roa.fzz
Schematics with Fritzing
Canzoni con telecomando qzm8kuxled

Code

Play MelodyC/C++
Copy this code in Arduino IDE
#include <LiquidCrystal.h>
#include <IRremote.h>
#include <NewTone.h>
#include <avr/io.h>
#include <avr/wdt.h>

#define Reset_AVR() wdt_enable(WDTO_30MS); while(1) {} 


#define buzzer 11     

LiquidCrystal lcd(9, 8, 7, 6, 5, 4);

int result;
int RECV_PIN=2;

IRrecv irrecv(RECV_PIN);

decode_results results;
  
void setup() {   
  Serial.begin(9600);               
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("-----Choose-----");
  lcd.setCursor(0,1);
  lcd.print("----A Song!!----");
  pinMode(buzzer, OUTPUT);
  irrecv.enableIRIn();
}  

void loop() {
  if (irrecv.decode(&results)) {
    result=results.value, HEX;
    Serial.println(result);
    if (result==12495) {
      ode();
    }
    else if (result==6375) {
      london();
    }
    else if (result==31365) {
      fur();
    }
    else if (result==4335) {
      pirate();
    }
    irrecv.resume();
  }
  delay(100);
} 

void fur() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Fur Elise");
  delay(1000);
  lcd.clear();
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_si(150,200);
  nota_rez(150,200);
  nota_do(150,200);
  nota_la(450,300);
  nota_do(150,200);
  nota_mi(150,200);
  nota_la(150,200);
  nota_si(450,300);
  nota_mi(150,200);
  nota_solz(150,200);
  nota_si(150,200);
  nota_do(450,300);
  nota_mi(150,200);
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_si(150,200);
  nota_rez(150,200);
  nota_do(150,200);
  nota_la(450,300);
  nota_do(150,200);
  nota_mi(150,200);
  nota_la(150,200);
  nota_sol(450,300);
  nota_mi(150,200);
  nota_do(150,200);
  nota_si(150,200);
  nota_la(600,800);
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_rez(150,200);
  nota_mi(150,200);
  nota_si(150,200);
  nota_rez(150,200);
  nota_do(150,200);
  nota_la(450,300);
  nota_do(150,200);
  nota_mi(150,200);
  nota_la(150,200);
  nota_si(450,300);
  nota_mi(150,200);
  nota_solz(150,200);
  nota_si(150,200);
  nota_do(450,300);
  lcd.clear();
  delay(100);
  Reset_AVR();
}

void london() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("London Bridge");
  lcd.setCursor(0,1);
  lcd.print("Is falling down");
  delay(1000);
  lcd.clear();
  nota_sol(450,600);
  nota_la(150,200);
  nota_sol(300,400);
  nota_fa(300,400);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(600,800);
  nota_re(300,400);
  nota_mi(300,400);
  nota_fa(600,800);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(600,800);
  nota_sol(450,600);
  nota_la(150,200);
  nota_sol(300,400);
  nota_fa(300,400);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(600,800);
  nota_re(600,800);
  nota_sol(600,800);
  nota_mi(300,400);
  nota_do(450,600);
  lcd.clear();
  delay(100);
  Reset_AVR();
}

void ode() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Ode to Joy");
  delay(1000);
  lcd.clear();
  nota_mi(300,400);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(300,400);
  nota_sol(300,400);
  nota_fa(300,400);
  nota_mi(300,400);
  nota_re(300,400);
  nota_do(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(300,400);
  nota_mi(450,600);
  nota_re(150,200);
  nota_re(600,800);
  nota_mi(300,400);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(300,400);
  nota_sol(300,400);
  nota_fa(300,400);
  nota_mi(300,400);
  nota_re(300,400);
  nota_do(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(300,400);
  nota_re(450,600);
  nota_do(150,200);
  nota_do(600,800);
  nota_re(300,400);
  nota_re(300,400);
  nota_mi(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(150,200);
  nota_fa(150,200);
  nota_mi(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(150,200);
  nota_fa(150,200);
  nota_mi(300,400);
  nota_re(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_sol(600,800);
  nota_mi(300,400);
  nota_mi(300,400);
  nota_fa(300,400);
  nota_sol(300,400);
  nota_sol(300,400);
  nota_fa(300,400);
  nota_mi(300,400);
  nota_re(300,400);
  nota_do(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(300,400);
  nota_re(450,600);
  nota_do(150,200);
  nota_do(600,800);
  lcd.clear();
  delay(100);
  Reset_AVR();
}

void pirate() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("He's a Pirate");
  delay(1000);
  lcd.clear();
  nota_mi(150,200);
  nota_sol(150,200);
  nota_la(300,400);
  nota_la(300,400);
  nota_la(150,200);
  nota_si(150,200);
  nota_do(300,400);
  nota_do(300,400);
  nota_do(150,200);
  nota_re(150,200);
  nota_si(300,400);
  nota_si(300,400);
  nota_la(150,200);
  nota_sol(150,200);
  nota_sol(150,200);
  nota_la(450,600);
  nota_mi(150,200);
  nota_sol(150,200);
  nota_la(300,400);
  nota_la(300,400);
  nota_la(150,200);
  nota_si(150,200);
  nota_do(300,400);
  nota_do(300,400);
  nota_do(150,200);
  nota_re(150,200);
  nota_si(300,400);
  nota_si(300,400);
  nota_la(150,200);
  nota_sol(150,200);
  nota_la(300,400);
  delay(400);
  nota_mi(150,200);
  nota_sol(150,200);
  nota_la(300,400);
  nota_la(300,400);
  nota_la(150,200);
  nota_do(150,200);
  nota_re(300,400);
  nota_re(300,400);
  nota_re(150,200);
  nota_mi(150,200);
  nota_fa(300,400);
  nota_fa(300,400);
  nota_mi(150,200);
  nota_re(150,200);
  nota_mi(150,200);
  nota_la(450,600);
  nota_la(150,200);
  nota_si(150,200);
  nota_do(300,400);
  nota_do(300,400);
  nota_re(300,400);
  nota_mi(150,200);
  nota_la(450,600);
  nota_la(150,200);
  nota_do(150,200);  
  nota_si(300,400);
  nota_si(300,400);
  nota_do(150,200);
  nota_la(150,200);
  nota_si(900,1200);
  nota_si(300,400);
  nota_si(300,400);
  nota_do(150,200);
  nota_la(150,200);
  nota_si(900,1200);
  nota_si(300,400);
  nota_si(300,400);
  nota_la(150,200);
  nota_sol(150,200);
  nota_la(600,800);
  lcd.clear();
  delay(100);
  Reset_AVR();
}

void shut() {
  if (irrecv.decode(&results)) {
    result=results.value, HEX;
    Serial.println(result);
    if (result==-23971) {
      Reset_AVR();
    }
  }
  irrecv.resume();
}

void nota_do(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Do    ");
  NewTone(11,262,duration); //DO
  delay(pause);
  }

void nota_doz(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Do #  ");
  NewTone(11,277,duration); //DO
  delay(pause);
  }

void nota_re(int duration, int pause) {
  shut;
  lcd.setCursor(0, 0);
  lcd.print("Re    ");
  NewTone(11,294,duration); //RE
  delay(pause);
  }

void nota_rez(int duration, int pause) {
  shut;
  lcd.setCursor(0, 0);
  lcd.print("Re #  ");
  NewTone(11,311,duration); //RE
  delay(pause);
  }

void nota_mi(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Mi    ");
  NewTone(11,330,duration); //MI
  delay(pause);
  }

void nota_fa(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Fa    ");
  NewTone(11,349,duration); //FA
  delay(pause);
  }

void nota_faz(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Fa #  ");
  NewTone(11,370,duration); //FA
  delay(pause);
  }


void nota_sol(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Sol   ");
  NewTone(11,392,duration); //SOL
  delay(pause);
  }

void nota_solz(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Sol # ");
  NewTone(11,415,duration); //SOL
  delay(pause);
  }

void nota_la(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("La    ");
  NewTone(11,440,duration); //LA
  delay(pause);
  } 

void nota_laz(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("La #  ");
  NewTone(11,466,duration); //LA
  delay(pause);
  }

void nota_si(int duration, int pause) {
  shut();
  lcd.setCursor(0, 0);
  lcd.print("Si    ");
  NewTone(11,494,duration); //SI
  delay(pause);
  }

Credits

Icona canale ulrv1z1uga
Simone Adobs

Hi, Hackster Community! I'm Simone Adobs and I am an Arduino fan. Take a look to all my projects! ;-)

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

LED To and Fro
Easy
  • 3
  • 2

Full instructions

Four LEDs blik alternatively to give a to and fro blinking

PHPoC: Web-Based Thermometer
Easy
  • 290
  • 13

Full instructions

This project allows you to check the temperature at home from anywhere using a web browser.

Arduino - Web-Based Joystick
Easy
  • 564
  • 13

Full instructions

This project shows how to control devices from anywhere using web-based joystick on smartphone.

Distance Indicator Using Ultrasonic Sensor
Easy
  • 151
  • 4

Work in progress

This project lights a set of LED's depending upon the distance of the obstacle with respect to the ultrasonic sensor.

Sorting Hat: Circuit Playground Express Starter Project
Easy
  • 158
  • 3

Protip

Which Hogwarts House do you belong in? A quick first project for this beginner-friendly board from Adafruit.

Grove starter kit for arduino --- Sound sensor
Easy
  • 5
  • 1

Protip

Teaches you how to use the sound sensor in the Arduino Grove starter kit.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login