Hi folks, I've tried numerous libraries and strings of code with no luck.
I'm running a nano into a WT5001-28p mp3 player board which relies on the Serial.Write to send packets to control it.
I've got it running the 3 audio tracks correctly and firing when buttons are pressed, but I need the reload sequence (track3) to only play once even when the button is held for an infinite amount of time.
(to imitate the cartridge being loaded) BUT can be overwritten by other audio commands. i.e fire, charging up etc.
please see below the (fairly short code) of the complete sketch.:
const int buttonPinFire = 7; // FIRE
const int buttonPinBlast = 8;
const int buttonPinBang = 9;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the button pin as a input:
pinMode(buttonPinFire, INPUT);
pinMode(buttonPinBlast, INPUT);
// initialize serial communication:
Serial.begin(9600);
// this is initiation sound on startup (track2 on SD card)
Serial.write(0x7E);
Serial.write(0x03);
Serial.write(0xA7);
Serial.write(0x19); // volume max
Serial.write(0x7E);
// start sound
Serial.write(0x7E);
Serial.write(0x04);
Serial.write(0xA0); // A0 for SD card
Serial.write((byte)0x00);
Serial.write(0x02); // track number
Serial.write(0x7E);
delay(3500);
}
void loop()
{
//this is the fire sequence audio (track 1 on SD card) pin7
Serial.write(0x7E);
Serial.write(0x02); //STOP Sound
Serial.write(0xA4);
Serial.write(0x7E);
buttonState = digitalRead(buttonPinFire);
if (buttonState == HIGH) {
Serial.write(0x7E);
Serial.write(0x04);
Serial.write(0xA0); // A0 for SD card
Serial.write((byte)0x00);
Serial.write(0x01); // track number
Serial.write(0x7E);
delay(1800);
}
// this is the reload sequence audio (track 3 on SD card) pin8
Serial.write(0x7E);
Serial.write(0x02); //STOP Sound
Serial.write(0xA4);
Serial.write(0x7E);
buttonState = digitalRead(buttonPinBlast);
if (buttonState == HIGH) {
Serial.write(0x7E);
Serial.write(0x04);
Serial.write(0xA0); // A0 for SD card
Serial.write((byte)0x00);
Serial.write(0x03); // track number
Serial.write(0x7E);
delay(1800);
}
}
It's the last section of code in the sketch.
any insight as to what I need to be doing would be greatly appreciated.
WastedProps