Code for PIR sensor

digitalWrite(pirPin, LOW); //start with no motion

think this line can screw up the working as pirPin was set as an INPUT.
The pirPin decides if there was motion or not , you cannot set it. (unless you make a MVC state machine and even then)

//give the sensor 30 seconds to calibrate
  Serial.print("Loading");
   for(int i = 0; i < 31; i++)
   {
      Serial.print(".");
      delay(1000);
   }

==> comments not needed if you use meaningfull strings varnames etc

  Serial.print("Callibrating");
   for(int  timeTillStart = 30; timeTillStart  > 0;  timeTillStart-- )
   {
      Serial.print(timeTillStart);
      Serial.print(" ");
      delay(1000);
   }

also this part

    ...
    val = LOW; // set val back to LOW  <<<<<<<< this line makes the second if always true, 
    
  }

  if(val == LOW);//When PIR gives a "LOW" do the following
  {