#include #include #include #include #define SD_ChipSelectPin 53 TMRpcm tmrpcm; int temp = 0; int Hour; int Minute; int Day; int Month; int Week; void setup() { Serial.begin(9600); Wire.begin(2); if (!SD.begin(53)) { Serial.println(F("initialization failed!")); while (1); } Serial.println(F("initialization done.")); tmrpcm.speakerPin = 5; tmrpcm.setVolume(5); Wire.onReceive (recieveEvent); } void loop() { Serial.println(temp); if (temp == 1) { play_lighton(); temp = 0; delay(500); } if (temp == 2) { play_lightoff(); temp = 0; delay(500); } if (temp == 3) { get_time(Hour, Minute); temp = 0; delay(500); } if (temp == 4) { play_yesboss(); temp = 0; delay(500); } if (temp == 5) { play_war(); temp = 0; delay(500); } if (temp == 6) { play_kimetsu(); temp = 0; delay(500); } if (temp == 7) { play_pirate(); temp = 0; delay(500); } if (temp == 8) { play_conginuadau(); delay(500); temp = 0; } if (temp == 9) { play_laugh(); temp = 0; delay(500); } if (temp == 10) { play_dog(); temp = 0; delay(500); } if (temp == 11) { play_jojo(); temp = 0; delay(500); } if (temp == 12){ get_day(Day,Month,Week); temp = 0; delay(500); } if (temp == 13){ play_1mintimeractivated(); temp = 0; delay(500); } if (temp == 14){ play_2mintimeractivated(); temp = 0; delay(500); } if (temp == 15){ play_3mintimeractivated(); temp = 0; delay(500); } if (temp == 16){ play_5mintimeractivated(); temp = 0; delay(500); } if (temp == 17){ play_15mintimeractivated(); temp = 0; delay(500); } if (temp == 18){ play_30mintimeractivated(); temp = 0; delay(500); } if (temp == 19){ play_1hourtimeractivated(); temp = 0; delay(500); } if (temp == 20){ play_timeout(); temp = 0; delay(500); } if (temp == 21){ play_choose_inteval(); temp = 0; delay(500); } } void recieveEvent(int dummy) { if (Wire.available()) { temp = Wire.read(); if ( temp == 3) { Hour = Wire.read(); Minute = Wire.read(); } if ( temp == 12 ) { Day = Wire.read(); Month = Wire.read(); Week = Wire.read(); } } } void get_day (const int &num1, const int &num2, const int &num3) { // num1 = day, num2 = moth, num3 = week switch (num3) { case 1: play_monday(); break; case 2: play_tuesday(); break; case 3: play_wednesday(); break; case 4: play_thursday(); break; case 5: play_friday(); break; case 6: play_saturday(); break; case 7: play_sunday(); break; } delay(500); switch (num2) { case 1: play_january(); break; case 2: play_febuary(); break; case 3: play_march(); break; case 4: play_april(); break; case 5: play_may(); break; case 6: play_june(); break; case 7: play_july(); break; case 8: play_august(); break; case 9: play_september(); break; case 10: play_october(); break; case 11: play_november(); break; case 12: play_december(); break; } delay(500); speak(num1); } void get_time(const int &num1, const int& num2) { if ( num1 <= 12) { //Serial.println(num1); speak(num1); } else { speak(num1 - 12); } delay(500); speak(num2); delay(500); if ( num1 < 12 ) { play_am(); } else { play_pm(); } } void speak(const int &num) { if ( num == 1) { play_1(); } if ( num == 2) { play_2(); } if ( num == 3) { play_3(); } if ( num == 4) { play_4(); } if ( num == 5) { play_5(); } if ( num == 6) { play_6(); } if ( num == 7) { play_7(); } if ( num == 8) { play_8(); } if ( num == 9) { play_9(); } if ( num == 10) { play_10(); } if ( num == 11) { play_11(); } if ( num == 12 ) { play_12(); } if ( num == 13) { play_13(); } if ( num == 14) { play_14(); } if ( num == 15) { play_15(); } if ( num == 16) { play_16(); } if ( num == 17) { play_17(); } if ( num == 18) { play_18(); } if ( num == 19) { play_19(); } if ( num == 20) { play_20(); } if ( num == 21) { play_21(); } if ( num == 22) { play_22(); } if ( num == 23) { play_23(); } if ( num == 24) { play_24(); } if ( num == 25) { play_25(); } if ( num == 26) { play_26(); } if ( num == 27) { play_27(); } if ( num == 28) { play_28(); } if ( num == 29) { play_29(); } if ( num == 30) { play_30(); } if ( num == 31) { play_31(); } if ( num == 32) { play_32(); } if ( num == 33) { play_33(); } if ( num == 34) { play_34(); } if ( num == 35) { play_35(); } if ( num == 36) { play_36(); } if ( num == 37) { play_37(); } if ( num == 38) { play_38(); } if ( num == 39) { play_39(); } if ( num == 40) { play_40(); } if ( num == 41) { play_41(); } if ( num == 42) { play_42(); } if ( num == 43) { play_43(); } if ( num == 44) { play_44(); } if ( num == 45) { play_45(); } if ( num == 46) { play_46(); } if ( num == 47) { play_47(); } if ( num == 48) { play_48(); } if ( num == 49) { play_49(); } if ( num == 50) { play_50(); } if ( num == 51) { play_51(); } if ( num == 52) { play_52(); } if ( num == 53) { play_53(); } if ( num == 54) { play_54(); } if ( num == 55) { tmrpcm.play("55.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } if ( num == 56) { tmrpcm.play("56.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } if ( num == 57) { tmrpcm.play("57.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } if ( num == 58) { tmrpcm.play("58.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } if ( num == 59) { tmrpcm.play("59.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } } void play_1mintimeractivated(){ tmrpcm.play("1mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_2mintimeractivated(){ tmrpcm.play("2mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_3mintimeractivated(){ tmrpcm.play("3mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_5mintimeractivated(){ tmrpcm.play("5mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_15mintimeractivated(){ tmrpcm.play("15mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_30mintimeractivated(){ tmrpcm.play("30mta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_1hourtimeractivated(){ tmrpcm.play("1hta.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_timeout(){ tmrpcm.play("timeout.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_choose_inteval(){ tmrpcm.play("cti.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_monday() { tmrpcm.play("mon.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_tuesday() { tmrpcm.play("tues.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_wednesday() { tmrpcm.play("wed.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_thursday() { tmrpcm.play("thurs.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_friday() { tmrpcm.play("frid.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_saturday() { tmrpcm.play("sat.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_sunday() { tmrpcm.play("sun.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_january() { tmrpcm.play("january.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_febuary() { tmrpcm.play("febuary.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_march() { tmrpcm.play("march.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_april() { tmrpcm.play("april.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_may() { tmrpcm.play("may.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_june() { tmrpcm.play("june.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_july() { tmrpcm.play("july.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_august() { tmrpcm.play("august.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_september() { tmrpcm.play("sept.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_october() { tmrpcm.play("october.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_november() { tmrpcm.play("november.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_december() { tmrpcm.play("december.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_1() { tmrpcm.play("1.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_2() { tmrpcm.play("2.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_3() { tmrpcm.play("3.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_4() { tmrpcm.play("4.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_5() { tmrpcm.play("5.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_6() { tmrpcm.play("6.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_7() { tmrpcm.play("7.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_8() { tmrpcm.play("8.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_9() { tmrpcm.play("9.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_10() { tmrpcm.play("10.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_11() { tmrpcm.play("11.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_12() { tmrpcm.play("12.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_13() { tmrpcm.play("13.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_14() { tmrpcm.play("14.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_15() { tmrpcm.play("15.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_16() { tmrpcm.play("16.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_17() { tmrpcm.play("17.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_18() { tmrpcm.play("18.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_19() { tmrpcm.play("19.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_20() { tmrpcm.play("20.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_21() { tmrpcm.play("21.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_22() { tmrpcm.play("22.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_23() { tmrpcm.play("23.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_24() { tmrpcm.play("24.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_25() { tmrpcm.play("25.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_26() { tmrpcm.play("26.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_27() { tmrpcm.play("27.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_28() { tmrpcm.play("28.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_29() { tmrpcm.play("29.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_30() { tmrpcm.play("30.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_31() { tmrpcm.play("31.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_32() { tmrpcm.play("32.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_33() { tmrpcm.play("33.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_34() { tmrpcm.play("34.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_35() { tmrpcm.play("35.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_36() { tmrpcm.play("36.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_37() { tmrpcm.play("37.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_38() { tmrpcm.play("38.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_39() { tmrpcm.play("39.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_40() { tmrpcm.play("40.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_41() { tmrpcm.play("41.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_42() { tmrpcm.play("42.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_43() { tmrpcm.play("43.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_44() { tmrpcm.play("44.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_45() { tmrpcm.play("45.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_46() { tmrpcm.play("46.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_47() { tmrpcm.play("47.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_48() { tmrpcm.play("48.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_49() { tmrpcm.play("49.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_50() { tmrpcm.play("50.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_51() { tmrpcm.play("51.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_52() { tmrpcm.play("52.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_53() { tmrpcm.play("53.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_54() { tmrpcm.play("54.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_am() { tmrpcm.play("am.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_pm() { tmrpcm.play("pm.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_yesboss() { tmrpcm.play("yesboss.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_lighton() { tmrpcm.play("lighton.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_lightoff() { tmrpcm.play("lightoff.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_conginuadau() { tmrpcm.play("congi.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_rocky() { tmrpcm.play("rocky.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_jojo() { tmrpcm.play("jojo.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_pirate() { tmrpcm.play("pirate.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_kimetsu() { tmrpcm.play("kimetsu.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_war() { tmrpcm.play("war.wav"); while (tmrpcm.isPlaying()) {}; tmrpcm.stopPlayback(); } void play_laugh() { tmrpcm.play("laugh.wav"); while (tmrpcm.isPlaying()) {} tmrpcm.stopPlayback(); } void play_dog() { tmrpcm.play("db.wav"); while (tmrpcm.isPlaying()) {} tmrpcm.stopPlayback(); }