Professional Documents
Culture Documents
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
#define BUTTON_PIN1 4
#define BUTTON_PIN2 5
#define BUTTON_PIN3 6
#define BUTTON_PIN4 7
#define BUTTON_PIN5 8
#define BUTTON_PIN6 9
#define BUTTON_PIN7 10
#define BUTTON_PIN8 11
#define BUTTON_PIN9 12
#define BUTTON_PIN10 13
#define PULLUP true //To keep things simple, we use the Arduino's internal
pullup resistor.
#define INVERT true //Since the pullup resistor will keep the pin high
unless the
//switch is closed, this is negative logic, i.e. a high state
//means the button is NOT pressed. (Assuming a normally open switch.)
#define DEBOUNCE_MS 20 //A debounce time of 20 milliseconds usually works well
for tactile button switches.
int a;
int b;
int c;
int d;
boolean ledState; //A variable that keeps the current LED status
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
void setup(void)
{
mySoftwareSerial.begin(9600);
Serial.begin(9600);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
void surya()
{
void loop(void)
{
// myBtn1.read(); //Read the button
// if (myBtn1.wasReleased()) { //If the button was released, change the
LED state
// myDFPlayer.play(y);
// Serial.println("tessss");
// }
fungsi();
myBtn1.read(); //Read the button
if (myBtn1.wasReleased()) { //If the button was released, change the LED
state
myDFPlayer.play(a);
a++;
Serial.println(a);
}
}
fungsi();
b = 3;
while (b < 6) {
fungsi();
myBtn2.read(); //Read the button
if (myBtn2.wasReleased()) { //If the button was released, change the LED
state
myDFPlayer.play(b);
b++;
Serial.println(b);
}
}
fungsi();
c = 6;
while (c < 8) {
fungsi();
myBtn3.read(); //Read the button
if (myBtn3.wasReleased()) { //If the button was released, change the LED
state
myDFPlayer.play(c);
c++;
Serial.println(c);
}
}
fungsi();
d = 8;
while (d < 10) {
fungsi();
myBtn4.read(); //Read the button
if (myBtn4.wasReleased()) { //If the button was released, change the LED
state
myDFPlayer.play(d);
d++;
Serial.println(d);
}
}
}
void fungsi () {
myBtn5.read(); //Read the button
if (myBtn5.wasReleased()) { //If the button was released, change the LED
state
myDFPlayer.pause(); //pause the mp3
Serial.println("play");
}