PIR Sensor not detect movement

Hi, I'm new to Arduino and I have a problem with PIR sensor. The lcd constantly keeping display no motion when I'm moving it. I tried to hold the breadboard, arduino uno and lcd but it still display no motion. Here is my code:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int led1 = 8;
int led2 = 9;
int buzzer = 11;
int button = 6;
int pir = 7;

void setup() {
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(6,INPUT);
  pinMode(7,INPUT);

  //lcd part
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  lcd.begin();
  lcd.backlight();
}

void loop() {
  //if statement part
  
  //check if pir sensor detect movement
    int sensorValue = digitalRead(7);
    if(sensorValue==HIGH){ 
    //blinking led
    //led on
    digitalWrite(8,HIGH);
    digitalWrite(9,HIGH);
    delay(1000);
    
    //buzzer sound
    tone(11,1000,1000);
    delay(1000);
    
    //lcd display
    lcd.setCursor(0,0);
    lcd.print("Detect Movement");
    delay(2000);

    //led off
    digitalWrite(8,LOW);
    digitalWrite(9,LOW);
    delay(1000);

    //buzzer off
    noTone(11);
  }
  else
  {
  //lcd detect no movement
    lcd.setCursor(0,0);
    lcd.print("No Movement");
    
    // led off
    digitalWrite(8,LOW);
    digitalWrite(9,LOW);

    //buzzer off
    noTone(11);
  }
}

Test your hardware first by keeping the code as simple as possible

Ensure the PIR has proper power with GND shared with arduino
Connect the PIR’s digital signal output pin to your arduino and configure that pirPin as INPUT and set the serial communication at 115200 bauds in setup

In loop just print the digitalRead of the pirPin and delay for 50ms

Upload and open the serial plotter

See if you get the expected outcome

PIRs require a bit of settling time (can be 30s) so values you read at first might not be relevant.

Some also have small potentiometers to adjust the sensitivity level for the digital output and duration of the trigger - make sure you adjust those too

Once this works - then you can add the LCD and whatever it is you want to achieve

Hint: They do not actually monitor movement they measure temperature and it it changes locations it is considered movement. If the object does not emit IR it will not be sensed. Try this link: How PIRs Work | PIR Motion Sensor | Adafruit Learning System

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.