Code only works correctly the first time?

Hi,
I have added Serial.prints to your code and edited some lines.
Open the IDE monitor with 9600baud.

The code does work just I think your LDR configuration in the circuit is back to front.

//Assign pins
int sensorPin = A0;     //light sensor
int pirSENSORPin = 2;      //SENSOR to detect motion, set to maximum sensitivity and range
int previousBUTTON = 4; //button on MP3 module
int playBUTTON = 3;     //button on MP3 module
int legLED = 5;         //leg red lights
bool PIRsensorStatus;
int ldrLevel;


void setup()
{
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  pinMode(pirSENSORPin, INPUT);
  pinMode(previousBUTTON, OUTPUT);
  pinMode(playBUTTON, OUTPUT);
  pinMode(legLED, OUTPUT);
  digitalWrite(previousBUTTON, HIGH); //set initial state, in my case Relay HIGH is OFF/OPEN
  digitalWrite(playBUTTON, HIGH);    //set initial state, in my case Relay HIGH is OFF/OPEN
  digitalWrite(legLED, HIGH);      //set initial state, in my case Relay HIGH is OFF/OPEN
}

void loop()
{
  ldrLevel = analogRead(sensorPin);
  PIRsensorStatus = digitalRead(pirSENSORPin);
  Serial.print("PIR Status = ");
  Serial.print(PIRsensorStatus);
  Serial.print("  LDR Level = ");
  Serial.println(ldrLevel);
  if ((ldrLevel <= 400) && (PIRsensorStatus == HIGH))     //If its dark outside and Motion is detected
  {
    //Play Sound
    Serial.println("Playing Sound");
    digitalWrite(previousBUTTON, LOW);     //PRESS previous button which plays sound from begining
    delay(100);
    digitalWrite(previousBUTTON, HIGH);    //release previous button
    delay(100);
    //Leg lighting sequence
    Serial.println("Start LED Sequence");
    digitalWrite(legLED, LOW);
    delay(8000);
    digitalWrite(legLED, HIGH);
    delay(100);
    //Stop Sound
    digitalWrite(playBUTTON, LOW);         //pause/stop the sound playback
    delay(100);
    digitalWrite(playBUTTON, HIGH);        //release play button
    Serial.println("Playing Released");
    //    delay(500);
    delay(60000);                          //wait 1minute before allowing to reactivate
  }
}

You do not need the "else" part of the if statement if you have nothing in it.

Tom... :smiley: :+1: :coffee: :australia: