help with pir triggering dc motor (solved-easy fix)

Im finishing a school project but i cant figure out the coding for the last piece. I need a pir sensor to start/turn the dc motor when the pir detects movement.

I have the wires setup like this: http://www.instructables.com/file/FYKU2PTI21RA4C6

Pir pins connected to:
Out- pin 12
vcc - pin 13
gnd-gnd (of course)

and the motorpin on 3.

The same instructable gives some coding help but it acts odd. The pir sensor seems blinks on/off and doesnt react to motion. It only blinks. The dc motor is also always on while the pir blinks. Then after 5-6 blinks the pir sensor shuts off perma. The sensor isnt broken either.

So I need code help to do these things:
I need the motor to turn on when the pir detect movement (sensor high)
and the motor need to turn off when the pir senses no motion (sensor low)

Please help me/thank you.
I am very new to coding also :confused:
Code I currently have:

const int pirPower = 12;
const int pirIn = 13;
int motorPin1 = 3;

void setup(){
pinMode(pirPower, OUTPUT);
pinMode(pirIn, INPUT);
pinMode(motorPin1, OUTPUT);
digitalWrite(motorPin1, LOW);
digitalWrite(pirPower, HIGH);
}

void loop(){
int value= digitalRead(pirIn);
if (value == HIGH){
digitalWrite(motorPin1, HIGH);
delay(1000);
int value= digitalRead(pirIn);
if (val == LOW){
digitalWrite(motorPin1, LOW);
}

ucoengrr:
Pir pins connected to:
Out- pin 12
vcc - pin 13

const int pirPower = 12;
const int pirIn = 13;

These two are not consistent.

ucoengrr:
const int pirPower = 12;
const int pirIn = 13;

"const" never changes.

A transistor needs a base resistor.
220ohm for a small motor.
The (unknown) transistor might already have gone to silicon heaven.

Uno?
Pin 13 should be avoided. It could be connected to the onboard LED that could blink during bootup.

How do you power the Arduino.
Leo..

Wawa:
These two are not consistent.

A transistor needs a base resistor.
220ohm for a small motor.
The (unknown) transistor might already have gone to silicon heaven.

How do you power the Arduino.
Leo..

My god. Lol. As soon as i fixed the pins it worked. However I do need to add the resistor. I un/intentionally left it out while looking through helps.

Where should I put the resistor?

ucoengrr:
Where should I put the resistor?

Between pin and base.
Leo..

Wawa:
Between pin and base.
Leo..

Right, just needed to move things around.

Alright, Im all done.

Thanks.