How to code for multiple PIR sensors.

Hello,

I have two PIR sensors (Sensein and SenseOut). In the past i built individual relay circuits which worked well but this time I wanted to use the Arduino. The sensors have delay adjustments so they provide a high for however I set these adjustments.

The sensors seem to be working correctly, but when SenseOut is triggered, I get Outdoor lamp ON then Outdoor Light OFF. When SenseIn is triggered, I only get Indoor Lights On.

I know it is the way I coded the sensors, and something to do with the LockLow, but frankly, I am having difficulty putting my head around it. Here is that code:

// This is Indoor sensor

if(digitalRead(SenseIn) == HIGH){

digitalWrite(LampIn, LOW); //Interior lamp ON

if(lockLow){

// Wait for transition

lockLow = false;

Serial.println(“\n\n”);

Serial.print(“Indoor Lights ON”);

Serial.println(" ");

Serial.println(“\n\n”);

delay(50);

}

takeLowTime = true;

}

// This is Outdoor sensor

if (digitalRead(SenseOut) == HIGH) {

digitalWrite(LampOut, LOW); //Exterior Lamp ON

if (lockLow) {

// Wait for transition

lockLow = false;

Serial.println(“\n\n”);

Serial.print(“Outdoor Light ON”);

Serial.println(“\n\n”);

delay(50);

}

takeLowTime = true;

}

if(digitalRead(SenseOut) == LOW){

digitalWrite(LampOut, HIGH); //The relay turns off

if(takeLowTime){

lowIn = millis(); //save the time of the transition from high to LOW

takeLowTime = false; //make sure this is only done at the start of a LOW phase

}

}

//if the sensor is low for more than the given pause,

//we assume that no more motion is going to happen

if(!lockLow && millis() - lowIn > pause){

//makes sure this block of code is only executed again after

//a new motion sequence has been detected

lockLow = true;

Serial.println(“\n\n”);

Serial.print(“Outdoor Light OFF”);

Serial.println(“\n\n”);

delay(50);

}

if(digitalRead(SenseIn) == LOW){

digitalWrite(LampIn, HIGH); //The relay turns off

if(takeLowTime){

lowIn = millis(); //save the time of the transition from high to LOW

takeLowTime = false; //make sure this is only done at the start of a LOW phase

}

}

//pause for any motion

if(!lockLow && millis() - lowIn > pause){

//makes sure this block of code is only executed again after

//a new motion sequence has been detected

lockLow = true;

Serial.println(“\n\n”);

Serial.print(“Indoor Light OFF”);

Serial.println(“\n\n”);

delay(50);

}

Any help in correcting this issue would greatly be appreciated.