Help reading two PIR Motion sensors to trigger two props

I am trying to trigger two different "scares" using two PIR Motion sensors.
Right now one prop keeps triggering back to back to back.
What SHOULD happen is if no motion is detected from either sensor an ambient audio track is played.
Motion from PIR1 triggers prop one "casket"
Motion from PIR2 triggers prop two "wolf"
there is a delay so someone does not trigger props back to back to back (even tho that is whats happening without any motion at all)

I have been playing with the code below and can not seem to get it right. Any and all help is so appreciated. Thank you for taking the time to look this over.

// started 10/06/2021 ajg
// libraries
#include <SPI.h>
#include <SdFat.h>
#include <vs1053_SdFat.h>
#include <Bounce2.h>

// input pins
int PIR1 = A1;
int PIR2 = A2;
int pirStateA = LOW;
int pirStateB = LOW; 
int valA = 0;
int valB = 0;
// output pins
#define Plug1 5
#define Plug2 4
#define Plug3 1
SdFat sd;
vs1053 MP3player;

void casket(){
    Serial.println(F("Trigger Casket"));
    MP3player.stopTrack(); //
    MP3player.playTrack(003); //play scream sound
    digitalWrite(Plug1, HIGH); //turns on plug
    Serial.print("Sound played and prop activated. Hahhaha They got scared!\n");
    Serial.print("10 second delay\n");
    Serial.print("relax and reset\n");
    digitalWrite(Plug1, LOW); //turns on plug
    //delay(45000); //delay to prevent triggering back to back ++++++++++++ BLOCK THIS LINE TO TEST
    Serial.print("I'm ready to scare!\n");
 pirStateA = LOW;

void wolf(){
  Serial.println(F("Trigger Prop two"));
    MP3player.stopTrack(); //
    MP3player.playTrack(003); //play sound
    Serial.print("Sound played and prop activated. Hahhaha They got scared again.\n");
    digitalWrite(Plug3, HIGH); //turns on light
    digitalWrite(Plug2, HIGH); //turns on plug
    digitalWrite(Plug2, LOW); //turns off plug
    digitalWrite(Plug2, HIGH); //turns on plug
    digitalWrite(Plug2, LOW); //turns off plug
    digitalWrite(Plug2, HIGH); //turns on plug
    digitalWrite(Plug2, LOW); //turns off plug
    digitalWrite(Plug2, HIGH); //turns on plug
    digitalWrite(Plug2, LOW); //turns off plug
    digitalWrite(Plug3, LOW); //turns on plug
    Serial.print("08 second delay\n");
    Serial.print("relax and reset\n");
    Serial.print("I'm ready to scare!\n");
 pirStateB = LOW;

void nothing(){
      if (!(millis() % 1000)) // prints a dot per second
    if (!(millis() % 60000)) // prints a new line once per minute
      Serial.println("Playing ambiant sounds/n");
    MP3player.playTrack(001); //play idal track sound

void setup() {

  Serial.begin(9600);      // open the serial port at 9600 bps:

  pinMode (PIR1, INPUT);
  pinMode (PIR2, INPUT);
  pinMode (Plug1, OUTPUT); //Pop up and strobe light
  pinMode (Plug2, OUTPUT); //activate Wolf 
  pinMode (Plug3, OUTPUT); //activate Light 

  if (!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

  MP3player.setVolume(10, 10);


void loop() 
  valA = digitalRead(PIR1); {// throw a ! in front of the digital Read if the signal goes low when active
    if (valA == HIGH); {
     // pirStateA = HIGH;
   if (digitalRead(PIR2)){
    if (valB == HIGH);{
      //pirStateB = HIGH;
  else {


Oops... as in I don't need the ; at the end of this code?

; by itself is the empty statement, so you have conditionally executed nothing. The if only applies to the immediate next statement or block be it empty or not.

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