// by Joseph P Rampolla
//   https://www.josephrampolla.com/

#include "SerialMP3Player.h"

#define TX 16
#define RX 17
int inPin1 = 12;  // IR sensor pin

SerialMP3Player mp3(RX,TX);
int value = 1;

void setup() {

  pinMode (inPin1, INPUT);  
  digitalWrite (inPin1, 1); 
  Serial.begin(9600);     // start serial interface
 
  mp3.begin(9600);        // start mp3-communication
  delay(500);             // wait for init

  mp3.sendCommand(CMD_SEL_DEV, 0, 2);   //select sd-card
  delay(500);             // wait for init
  
}


void loop()
{ 
 for (;;) {
  int value = digitalRead(12);
   if(value == 0) {   // sensor triggered
 
  mp3.setVol(30);     // highest volume
  mp3.play(001);     // play file 1 or 1st file added to SD card
  delay(28000);
  break; 
   }
  }
   for (;;) {
  int value = digitalRead(12);
   if(value == 0) {     // sensor triggered

  mp3.play(002);     // play file 2 or 2nd file added to SD card
  delay(1000);  
   break; }}
  }
 



      The site owner is not and cannot be held liable for fire, electrical shock, property damage, bodily injury, loss of life, or accident of any kind caused by electrical circuits or any ideas, projects, techniques, or information contained on this site. The visitor assumes all risk and responsibility for any loss, injury, accident or damage arising from the use of information, ideas, techniques, projects, concepts, components, products, and circuits on this site.

      Please refer to hobby reference materials for correct and safe use information regarding these and all electronic circuits.  These diagrams are intended to explain how things were accomplished in theory, but it is the responsibility of the individual to locate precise information regarding electrical circuits, materials, ratings of components, etc.  Do not attempt these hobby projects, or any electrical project, if you don't have the necessary skills and experience.

[back to main page]