Help with PIR Motion Sensor


I got a Seeduino + buzzer + PIR Motion Sensor. My code is pasted further below.

For some reason, the PIR seems inconsistent in its behavior. I start the system and it sees nothing (which is fine), then I walk up to it and it sometimes detects me, sometimes not. When it DOES detect me, it doesn’t stop even when I move away.

I assume its related to the holding time, but how do I verify? What’s the default holding time (I didn’t solder on a potentiometer or anything).


const int LED = 13;

const int PIR = A4;

const int BUZZER = A5;

void setup() {

pinMode(LED, OUTPUT);


pinMode(PIR, INPUT);



void loop() {

if (digitalRead(PIR)) {


digitalWrite(LED, HIGH);

digitalWrite(BUZZER, HIGH);

} else {


digitalWrite(LED, LOW);

digitalWrite(BUZZER, LOW);




BTW - I waited several minutes and the PIR sensor still hasn’t gone off after triggering (tried this several times)

Hi litelite,

I tried and succeeded, there are two suggestions:

Firstly, set the holding time longer, for example, 1s. And then put the PIR on you front, the effect will be better.



What holding timer? The delay in the code itself? Or the timer on the PIR itself? If on the PIR itself, how do I change the timer?

Hi there,

  1. please change to delay(200) to delay(1000).
  2. for the PIR hardware, it uses TM2291, Pin3 and Pin4 can define the delay time as well. the delay time is Tx≈40000R1C1.

    here is the TM2291 reference circuit.

    here is the pir sensor circuit. the R6 is not placed(DNP). So only with R14(10K) resistor and 10nf capacitor. base on Tx≈40000R1C1=4s, we can add resistor on R6 place to reduce the resistor. thanks.