Help coding PIR sensor and servo

I'm new to Arduino and need a lot of help with what I'm trying to do.
For a class project I want to construct a monster (Halloween style animations). I want to rig the head with a PIR sensor (two preferably to react to both sides of the room) to rotate 45 degrees in the direction of motion.
I think I understand how I'm suppose to code it but I'm not trying them correctly.
I've been reading a lot of tutorials and get some parts right but then destroy others.
This is where am at so far:

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
    // a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
 myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
 for(pos = 0; pos < 45; pos += 1) // goes from 0 degrees to 180 degrees
 {         // in steps of 1 degree
 myservo.write(pos);    // tell servo to go to position in
          // variable 'pos'
 delay(50);      // waits 50ms for the servo to reach
          // the position
 }
 for(pos = 45; pos>=1; pos-=1)  // goes from 180 degrees to 0 degrees
 {       
 myservo.write(pos);    // tell servo to go to position in
          // variable 'pos'
 delay(50);      // waits 50ms for the servo to reach
          // the position
 }       
}

I also need it to pause a few seconds before returning to the original position.
Can someone please help me code it properly.

arrange the servo such that 90 deg is forward.
loop down to 45 to turn one direction and up to 135 for the other.