Skip to main content

MP3 sound control

This simple project will use a mp3 player, a simple, recycled speaker, and arduino and a HLK-LD2420 human motion sensor to play sounds when a human walks past the device. 

 

sketch code:

 

#include <SoftwareSerial.h>

// define the digital pins to use as RX and TX for two
// software serial connections
const int RX1 = 8;
const int TX1 = 9;
const int RX2 = 10;
const int TX2 = 11;

// create SoftwareSerial objects
SoftwareSerial SoftSerialOne(RX1,TX1);
SoftwareSerial SoftSerialTwo(RX2,TX2);

void setup(void) {
// setup the software serial pins
pinMode(RX1, INPUT);
pinMode(RX2, INPUT);
pinMode(TX1, OUTPUT);
pinMode(TX2, OUTPUT);
}

void loop(void) {
SoftSerialOne.begin(9600); // begin communication on the first 
// software serial channel
SoftSerialOne.print("Hello World"); // send something
SoftSerialOne.end(); // end communication on the first software
// serial channel
SoftSerialTwo.begin(9600); // begin communication on the second 
// software serial channel
SoftSerialTwo.print("Hello World"); // send something
SoftSerialTwo.end(); // end communication on the second software
// serial channel
}