#include <Keypad.h>
// LiquidCrystal - Version: Latest
#include <LiquidCrystal.h>
char songnum[2];
int currentlength = 0;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd(7,9,10,11,12,13); // the pins we use on the LCD
int P = 8;
void setup() {
#define e 329.63
#define d 293.66
#define c 261.63
#define g 392.00
lcd.begin(16,2);
lcd.print("choose a song:");
lcd.setCursor(0, 1);
lcd.cursor();
Serial.begin(9600);
songnum[1]=0;
songnum[2]=0;
while(currentlength<2){
char key = keypad.getKey();
key == NO_KEY;
if (key != NO_KEY)
{
if ((key != '*')&&(key != '#'))
{
lcd.print(key);
songnum[currentlength] = key;
currentlength++;
}
}
}
}
void loop() {
if ((currentlength==2)&&(songnum[1]==1)){
tone(P, e, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, c, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, e, 250);
delay(500);
tone(P, e, 250);
delay(500);
tone(P, e, 500);
delay(1000);
tone(P, d, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, d, 500);
delay(1000);
tone(P, e, 250);
delay(500);
tone(P, g, 250);
delay(500);
tone(P, g, 500);
delay(1000);
tone(P, e, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, c, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, e, 250);
delay(500);
tone(P, e, 250);
delay(500);
tone(P, e, 500);
delay(1000);
tone(P, d, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, e, 250);
delay(500);
tone(P, d, 250);
delay(500);
tone(P, c, 1000);
delay(1500);
lcd.print(songnum[1]);
currentlength++;
}
}