Running a DC motor for a set amount of time
#include &lt;Arduino.h&gt;

const int pirPin = 9;
const int motorPin = 2;
int switchState = 0;
// the setup routine runs once when you press reset:
void setup()
{
 // initialize the digital pin as an output.
 pinMode(motorPin, OUTPUT);
 pinMode(pirPin, INPUT);
}
void loop()
{
 while (digitalRead(pirPin) == HIGH)//this part of the code gets executed if the pir 
 //pin is read high
 {
   digitalWrite(motorPin, HIGH);//the motor pin is set high so if a motor is connected 
   //the motor will start turning. 
 }
 while (digitalRead(pirPin) == LOW)//this part of the code gets executed if the pir 
 //pin is read low
 {
   delay(100);// so your motor stop after running for extra 0.1 seconds 
   digitalWrite(motorPin, LOW);//the pin gets low and the motor should stop turning
 }
}

I have commented all the lines
Hope this helps.