#include #include int sw1 = 8; int sw2 = 9; int sw3 = 10; void setup () { Serial.begin (9600); mp3_set_serial (Serial); //set Serial for DFPlayer-mini mp3 module delay(1); // delay 1ms to set volume mp3_set_volume (15); // value 0~30 pinMode(sw1, INPUT_PULLUP); pinMode(sw2, INPUT_PULLUP); pinMode(sw3, INPUT_PULLUP); } void loop () { if(digitalRead(sw1) == LOW) { mp3_play (1); delay(5000); mp3_stop (); } else if(digitalRead(sw2) == LOW) { mp3_play (2); delay(5000); mp3_stop (); } else if(digitalRead(sw3) == LOW) { mp3_play (3); delay(5000); mp3_stop (); } }
|