#include < SoftwareSerial.h >
#include < DFRobotDFPlayerMini.h >
SoftwareSerial mySerial(16, 17); // RX, TX for DFPlayer Mini
DFRobotDFPlayerMini myDFPlayer;
int soundSensorPin = 34; // Analog or Digital pin connected to sound sensor
int threshold = 500; // Threshold value for sound sensor
void setup() {
Serial.begin(115200);
mySerial.begin(9600);
if (!myDFPlayer.begin(mySerial)) {
Serial.println("DFPlayer Mini not detected");
while (true); // Stop program if DFPlayer is not connected
}
myDFPlayer.volume(10); // Set volume level (0-30)
myDFPlayer.play(1); // Play the first audio file as a test
pinMode(soundSensorPin, INPUT); // Set sound sensor pin as input