const byte koniecczasu = 4; const byte wygrana = 5; const byte pilot = 6; bool a = 0; bool b = 0; bool c = 0; // biblioteki do dzwięku // #include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h" SoftwareSerial mySoftwareSerial(10, 11); // RX, TX DFRobotDFPlayerMini myDFPlayer; void setup() { // put your setup code here, to run once: mySoftwareSerial.begin(9600); Serial.begin(115200); if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3. Serial.println(F("Unable to begin:")); Serial.println(F("1.Please recheck the connection!")); Serial.println(F("2.Please insert the SD card!")); while(true); } pinMode(koniecczasu, INPUT_PULLUP); pinMode(wygrana, INPUT_PULLUP); pinMode(pilot, INPUT_PULLUP); myDFPlayer.setTimeOut(200); myDFPlayer.play(2); } /* utwory * 000 - wstep * 001 - niepowodzenie * 002 - muzyka * 003 - wygrana * * 1- przegrana * 2- uratowanie * 3- wstep * 4- podkład * * */ void loop() { if ((digitalRead(pilot) == HIGH) && (c == 0)){ c = 1; Serial.println("c - wstep"); myDFPlayer.volume(21); delay(1000); myDFPlayer.play(3);// 000 wstęp do gry delay(61000); Serial.println("koniec wstepu"); myDFPlayer.volume(18); delay(300); myDFPlayer.play(4); } if ((digitalRead(koniecczasu) == LOW) && (a==0)){ a=1; Serial.println("a - koniec czasu"); myDFPlayer.volume(21); delay(300); myDFPlayer.play(1); //001 koniec czasu delay(34000); myDFPlayer.volume(18); delay(300); myDFPlayer.play(4); Serial.println("koniec ifa koniec czasu"); } if ((digitalRead(wygrana) == LOW) && (b==0)){ b=1; Serial.println("b - wygrana"); myDFPlayer.volume(21); delay(300); myDFPlayer.play(2); //003 wygrana Serial.println("koniec ifa wygrana "); } delay(500); Serial.println("kolo"); Serial.println("koniecczasu: "); Serial.print(digitalRead(koniecczasu)); Serial.println("wygrana: "); Serial.print(digitalRead(wygrana)); Serial.println("koniecczasu: "); Serial.print(digitalRead(pilot)); }