This thing is really bugging me. I have triple double checked the wiring 10 million times. The PIR on digital 2 keeps triggering and calling the alert function and printing the sensor value as triggered when it IS NOT BEING TRIGGERED. The compiler doesn't find anything to whine about. I am using an inland UNO I got from Micro Center.(I lost my legit UNO) If anyone can help it would be greatly appreciated. PS I have swapped the sensor out 3 times. :
int PIR_output = 1;
int PIR_output2 = 12; // SENSOR inputs
int ALERT2 = 8; // RED lights
int ALERT1 = 7; // WHITE lights
void setup() {
Serial.begin(9600);
pinMode(12, INPUT); // starts setting inputs and outputs
delay(100);
pinMode(1, INPUT);
pinMode(ALERT1, OUTPUT);
pinMode(ALERT2, OUTPUT);
Serial.println("Inputs and Outputs set");
Serial.println("Awaiting Calibration for 10 secs");
digitalWrite(ALERT1, HIGH);// there are two sets of LEDs and they both stay solid for the calibration process
digitalWrite(ALERT2, HIGH);// the first one sets the first set and this sets the other
delay(10000);// 10sec calibration process to give the sensors time to warm up
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, LOW);
delay(750);
digitalWrite(ALERT1, HIGH);
digitalWrite(ALERT2, HIGH);
delay(200);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, LOW);
delay(200);
digitalWrite(ALERT1, HIGH);
digitalWrite(ALERT2, HIGH);
delay(200);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, LOW);// this flashes both light sets in unison to alert the user that the calibration is finished
Serial.println("Calibration Complete");
}
void alert() // this is what flashes the lights once the sensor values are read
{
Serial.println("FUNCTION CALLED: Flashing ALERT LEDs");
void loop(); {
digitalWrite(ALERT1, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT2, LOW);
digitalWrite(ALERT1, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT2, LOW);
digitalWrite(ALERT1, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT2, LOW);
digitalWrite(ALERT1, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT2, LOW);
digitalWrite(ALERT1, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT1, LOW);
digitalWrite(ALERT2, HIGH);
delay(800);
digitalWrite(ALERT2, LOW);// these flash the lights 1 on 1 off 2 on 2 off
Serial.println("ALERT OVER");// debugging
delay(500);// delay cause why not
}
}
void loop() {
if (digitalRead(PIR_output2) == HIGH) // listens for the alert signal from the PIR
{
Serial.println("Guest Bed HALL MOTION: CALLING ALERT");
alert(); // signals the alert function to flash the lights
}
if (digitalRead(PIR_output) == HIGH) // listens for the alert signal from the PIR
{
Serial.println("Master Bed HALL MOTION: CALLING ALERT");
alert(); // signals the alert function to flash the lights
}
Serial.println(digitalRead(PIR_output2));// gives SM debugging data
Serial.println(digitalRead(PIR_output));// same down here
}