Halloween prop controller

Everything I see is one UNO being used for like one item. I see all the inputs and output we can use and have tried to use at least 4 or 5 PIR's to activate store-bought Halloween props. Basically use the "Try Me" button circuit. Might use relays to trigger the prop once the PIR is triggered. I'm looking at the "millis()" code to see if it improves the response time.

Can the UNO be used for multiple inputs and outputs? I noticed in the Stimulator in Tinkercad I have slight delays as the PIR's are triggered.

I may change it to using the PIR's individually with each prop.

As a newbie to programming, I'm just seeing what can be done. Any Thoughts?

int skullLED=12;
int mailbox=13;
int singing=11;
int mib=10;
//PIR
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int sensor1=4; //skull
int sensor2=5; //mailbox
int sensor3=3; //singingheads
int sensor4=2; //Monster in Box

void setup() {
  pinMode(skullLED, OUTPUT);      // declare LED as output
  pinMode(sensor1, INPUT);     // declare sensor as input
  pinMode(mailbox, OUTPUT);      // declare LED as output
  pinMode(sensor2, INPUT);     // declare sensor as input
  pinMode(singing, OUTPUT);      // declare LED as output
  pinMode(sensor3, INPUT);     // declare sensor as input
  pinMode(mib, OUTPUT);      // declare LED as output
  pinMode(sensor4,INPUT);     // declare sensor as input
  Serial.begin(9600);
}
void loop(){
  val = digitalRead(sensor1);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(skullLED, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected at Skull!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(skullLED, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }

//mailbox sensor
val = digitalRead(sensor2);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(mailbox, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected at Mailbx!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(mailbox, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended at Mailbox!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
    val = digitalRead(sensor3);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(singing, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected at Singing Skulls!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(singing, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }

//mailbox sensor
val = digitalRead(sensor4);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(mib, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected at MIB!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(mib, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended at MIB!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
}
  }}

I do not see a question.

Using the IDE autoformat tool (ctrl-t or Tools, Auto Format) would improve readability of your code.

The way I read this, you have 4 "sensors" that act as "triggers" to activate 4 Halloween decorations.

Are you worried that if you trigger one thing, you might miss the next trigger on a different sensor?

I'd think the response time of the above code would be quick enough that the average person would see it as automatic.

I'm assuming you are going to limit the range of the PIR's down only have a few degrees?

johnnycatt:
The way I read this, you have 4 "sensors" that act as "triggers" to activate 4 Halloween decorations.

I'm assuming you are going to limit the range of the PIR's down only have a few degrees?

Yes, you have it correct. I don't plan to have the props close together so a little delay won't be bad. I was just curious if there might be a better way. Most Youtube videos and such basically show one prop per Arduino.

Since the Arduino has all those inputs, why not use them!

Hi,
Distance between props won't cause a delay, the PIRs usually have this feature to make sure they trigger on a solid IR source.

If you keep your wiring neat and away from mains powered AC lines, you should not have a problem.
If the UNO has enough I/O for your needs then for simple servo, lights type props you should be okay.

Hint: Don't take Tinkercad simulation as gospel, there is more satisfaction in building and experimenting in the real world.

Tom... :slight_smile:

Thanks Tom,

No, I am not taking Tinkercad as gospel but it's handy.

I just see all this potential not to attempt to use it all.

Thanks

Why would you use a UNO?