PIR Sensor + Relay + Button + Time = Im Lost

I have:
arduino Micro
PIR Sensor module
Relay module
Button with light

This is what I want it to do:
I walk in the house at the end of the day, sensor see me, lights on. When I am watching tv right before bed and want the lights off I hit the button. I can walk around during the 4 hours to do what I want and lights don’t come on.

When I wake up in the morning the sensor will have passed its 4 hour time and be ready for me. Once it sees me it will come on. Then when I am ready to leave for the day I will hit the button and it will turn off the lights and arm the sensor in 5 minutes.

I have attached what I have been working on. Any help is appreciated.

Back_up_work_without_button.ino.ino (1.25 KB)

Have you read "planning and implementing an Arduino program" ..?
It's in useful links at the top of this section.

I have been reading and watching videos for days…all tutorials usually just one thing…It is hard to understand and write code when I have multiple things going on like this one. I’m doing the best I can.

int calibrationTime = 15;   //the time we give the sensor to calibrate
int pirPin = 3;    //pin connected to the PIR sensor's output
int relayPin = 12;    //pin connected to the relay
int buttonLight = 6;   //On and Off Button Light
int buttonPin = 2;    //pin for the button

void setup(){
  pinMode(pirPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(buttonLight, OUTPUT);
  pinMode(buttonPin, INPUT);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");

void loop(){

int sensorValue = digitalRead(pirPin);    //declaring sensorValue to equal the tigger of PIR Sensor

     if(sensorValue == HIGH){   //sensor is triggered 
       digitalWrite(relayPin, LOW);   //turn on the relay
       Serial.println("On");    //write on
       digitalWrite(buttonLight, LOW);    //make the button light off
       digitalWrite(relayPin, HIGH);  //turn off the relay
       Serial.println("Off");   //write off
       digitalWrite(buttonLight, HIGH);   //make the button light on       

Multiple things going on is exactly what the link I referred to addresses.

Do you have a wiring diagram of your setup?

How is your arduino supposed to know the difference between the evening, when you want a four hour delay, and the morning, when you only want a five minute delay?

Please re-read your post, as though it was an assignment at work. Can YOU understand what the code is supposed to do (regardless of whether or not you can write the code to do it)?

I can walk around during the 4 hours to do what I want

What 4 hours? This is the first time you've mentioned a time frame, but you have not defined when the time frame starts, or what happens during that time frame.

When I wake up in the morning the sensor will have passed its 4 hour time and be ready for me.

There is NO relationship between the sensor and a time frame. The Arduino/programmer needs to read, or not read, the sensor on every pass through loop(). The Arduino/programmer needs to be concerned about, or not, the value read from the sensor, depending on what time it is (absolute or relative to some event).

If you can't explain clearly what your requirements are, you'll never be able to write the code to implement them.

So, lets work on getting the requirements written properly first.