PIR problems

Hi all,

Since a long time i started another project, involving a 3VDC motor, triggered by the PIR sensor.

Ive connected it using a test code, and i see it is working well in the Monitor.
Now, for my project i am using a code which ive not written, but i sort of understand (im not yet very knowledgable in the programming part..)

So i know the sensor works, and my eventual code uses different pins on the Uno, but i cant figure out whats wrong here..

the code is this one:

const int pirPower = 13;
const int pirIn = 12;
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(500);
digitalWrite(motorPin1, LOW);
}
}

now the PIR sensor is on 12, 13, and GND, and does absolutely nothing..
Ive seen the YT video of the guy writing out this code and using the exact same pins and he has no problems at all..

Any help is great help! Thanks in advance!

do you have the motor to ground? Did you put a flyback diode on it? Is the motor drawing too much current? Please include schematic or pictures.

Does the PIR have an Open Collector (or Open Drain) output? If so, it needs a pull-up resistor. Try setting "pinMode(pirIn, INPUT_PULLUP);" instead of just INPUT.

Try adding " pinMode(LED_BUILTIN, OUTPUT);" in setup() and adding " digitalWrite(LED_BUILTIN, value);" in loop(), right after " int value = digitalRead(pirIn);". Then the built-in LED will show you the state of the PIR input. If the LED is not turning on and off then something is wrong with the PIR, possibly a faulty unit or bad connection.