Loading...
Loading...
// DFPlayer sound trigger
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
DFRobotDFPlayerMini player;
const int SENSOR = 2;
void setup() {
mySerial.begin(9600);
player.begin(mySerial);
player.volume(20);
pinMode(SENSOR, INPUT);
}
void loop() {
if (digitalRead(SENSOR) == LOW) {
player.play(1); // Play track 1
delay(5000); // Debounce
}
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.