YX-5300 coding help

Hi all im very new to the world of ardunio but am learning slowly so please bear that in mind
so the project is for a escape room prop we have a old rotary phone and thie set up is as follows
using a motion sensor a person is detected and the phone will ring (play track 1 on the mp3 module of a ringing phone ) then when they pick the handset up the switch on the phone is linked to a Digital pin and acts as a normal switch switching the output to LOW (as its set to high when the handset is down ) what i want to do is upon the handset being picked up for it to skip to track 2 "some audio which gives a clue " (this can loop whilst the handset is lifted if thats easyer )
but then for the phone to be about to "reset" ready for the next group of players and start the cycle again ? this is the code i wrote so far but i need help thank you

#include <MD_YX5300.h>
#include "SerialMP3Player.h"
#define TX 11
#define RX 10
int Sensor = 2;
int state = LOW; 
int Val = 0; 
int Switch =5;
int SwitchVal=1;
const int ResetPin=3;


SerialMP3Player mp3(RX,TX);
void setup() {
  Serial.begin(9600);     // start serial interface
  pinMode (Sensor,INPUT);
  pinMode (Switch, INPUT);
  pinMode (ResetPin,OUTPUT);
  digitalWrite (ResetPin, HIGH);
   


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
  
}

// the loop function runs over and over again forever
void loop() 
{
  Val=digitalRead(Sensor);
  SwitchVal=digitalRead(Switch);
  if (Val=HIGH);    
  Serial.println ("motion detected ! ") ;
  delay (50);
 mp3.play();
  delay(5000);    // wait 10 seconds for answer }
  digitalWrite(ResetPin,LOW);
delay (100);
Val=digitalRead(Sensor);
  SwitchVal=digitalRead(Switch);
if (Val==HIGH&&SwitchVal==LOW);
mp3.play(002);}
1 Like

Welcome. You may find your code easier to follow if you format it in the IDE. It's CTRL-T on Win10 (not sure about linux etc).

Have a read of:

to see how to use the if statement correctly.

1 Like

#include <MD_YX5300.h>
You are not using this library so no need to include it.
if (Val=HIGH);
At least 2 things wrong with this and similarly here
if (Val==HIGH&&SwitchVal==LOW);
loop() does not seem to have a closing brace.

1 Like

Same.

It's the same as Windows 10 just checked thanks guysb

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.