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;
}
}
}
}
}}