Very easy Arduino code challenge for you brainiacs to solve I've searched the forum for similar problems and still can't see my obvious issue. I'm working on a simple Halloween prop and I'm using an Arduino for the first time. I've tested each individual 'event' (i.e. fog machine, mp3, actuator, and LED strip) with a loop and all four have worked on continuous loop with no issue.

As soon as I combine them all together, the program runs successfully exactly one time. After that final 10 second delay, when I expect the program to start the loop again, it crashes. If it helps, right during the start of the next loop, the relay light turns on on the relay board for RELAY_1_A and sort of just flickers while the actuator hums. I usually shut it down quickly at this point. As soon as I turn the system back on, it successfully runs through another iteration until the loop hangs.

I'm happy to provide pictures or even a video of the issue if that helps. My guess is that you guys will spot my coding issue right away. Maybe some kind of memory overflow or something like that.

I know my code could be much more efficient but I'm just looking for the glaring problem that is keeping the loop from working.

#include &lt;SPI.h&gt;
#include &lt;SdFat.h&gt;
#include &lt;SdFatUtil.h&gt; 
#include &lt;SFEMP3Shield.h&gt;

const int RELAY_1_A = 7; //the one with the issue
const int RELAY_1_B = 8;

SdFat sd;
SFEMP3Shield MP3player;
void setup() {                
  // initialize the digital pins as an output.
  pinMode(10, OUTPUT); //Fog machine on Relay1 on 5V relay board
  pinMode(3, OUTPUT); //LED strip off breadboard MOSFET  
   pinMode(RELAY_1_A, OUTPUT); //12V relay for actuator on Relay1 on 12V relay board
   pinMode(RELAY_1_B, OUTPUT); //12V relay for actuator on Relay2 on 12V relay board

  //start the shield
  sd.begin(SD_SEL, SPI_FULL_SPEED);
  MP3player.begin();
  MP3player.setVolume(10, 10);
}

void loop() {
  MP3player.playTrack(2);  // Play MP3. Track 1 is coffin and track 2 is bird
  delay(5000);              // wait for 5 seconds
  digitalWrite(10, LOW);   // Turns ON fog machine
  delay(3000);
  digitalWrite(10, HIGH);   // Turns OFF fog machine 
  digitalWrite(3, HIGH);   // Turn the LED on (HIGH is the voltage level)

  delay(5000);              // wait for 5 seconds

  retractActuator();       //Open coffin
  delay (9000);
  stopActuator();      //Close coffin
  delay (9000);
  extendActuator();      //Close coffin
  delay(8000);              
  digitalWrite(RELAY_1_B, HIGH);  //Turns off this relay during the wait period before next loop

  digitalWrite(3, LOW);    // Turn the LED off by making the voltage LOW
  delay(10000);              // wait for 20 seconds

}
void extendActuator() {
  //Set one relay one and the other off
  //this will move extend the actuator
  digitalWrite(RELAY_1_A, HIGH);
  digitalWrite(RELAY_1_B, LOW);
}

void retractActuator() { 
  //Set one relay off and the other on 
  //this will move retract the actuator 
  digitalWrite(RELAY_1_A, LOW);
  digitalWrite(RELAY_1_B, HIGH); 
}

void stopActuator() {
 //Set both relays off
 //this will stop the actuator in a braking
 digitalWrite(RELAY_1_A, HIGH);
 digitalWrite(RELAY_1_B, HIGH); }
You are attempting to use IO pins that are already in use by the MP3 shield.

According to your subsequent research, only digital pins 0,1,5, and 10 are available for use.

You should shy away from using pins 0 and 1 since they are also connected to the computer through the USB interface and are used for uploading sketches.  You will find that either you can't upload sketches with the relays connected to those pins, or the relays will "randomly" switch on and off while you're uploading a sketch.

Don't forget that the analog pins A0-A5 can also be used as digital pins, so you can quite happily drive your relays using any of those.