PIR sensor digital read only returns low or 0

//Library
#include <LiquidCrystal.h>

//Setting up the pins for the LCD, buzzer, and LED
//Set up LCD layout
const int rs = 2, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int sensor1 = 11;
//Giving the motion sensors a default state
int val;
//Set up the buzzer and LED pins
int ledPin = 10;
int buzzerPin = 9;

//Initialize all of the pins. Setting up INPUT/OUTPUTS. 
void setup() {//Start void setup
 pinMode(buzzerPin, OUTPUT);
 pinMode(ledPin, OUTPUT);
 pinMode(sensor1, INPUT);
 lcd.begin(16, 2);
//Power on test  
  lcd.print("Powering On!");
  digitalWrite(ledPin, HIGH);
  digitalWrite(buzzerPin, HIGH);
  delay(1000);
  lcd.clear();
  Serial.begin(9600);
}//End of void setup

void loop() {//Start void loop
 
  val = digitalRead(sensor1); 
  //PROBLEM: Above line is not reading sensor values
  
  //If PIR is at a HIGH state/motion -> Print to lcd/Serial  
  if (val == HIGH) {
    delay(500);
//Printing to the LCD/serial
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Motion");
    lcd.setCursor(0,0);
    lcd.print("Detected");
    Serial.println("Motion Detected");
//Turn on the LED and buzzer
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    Serial.println(val);
    delay(500);
  	
  }//End of high if
  
  
//If PIR is at a LOW state/no motion -> Print to lcd/serial  
  if (val == LOW) {
    delay(500);
//Printing to the LCD/serial
    lcd.clear();
    lcd.print("Nothing");
    Serial.println("Nothing");
//Turn off LED and buzzer  
    digitalWrite(ledPin, LOW);
    digitalWrite(buzzerPin, LOW);
    delay(500);
    Serial.println(val);
    
  }//End of PIR LOW if  
  

   
  
    }//End of void loop

The circuit is on tinkercad. The PIR sensor is stuck returning low, and never returns a high when triggered. How can I get it to start returning the proper values?

You need a GND connection to the sensor.

A circuit has to be a loop, otherwise no current can flow. This is why there are at least two wires between
any two parts of a correct circuit.

The exception is a radio antenna, but that’s not what you want here!

Common all the grounds, ground is the common return path for current in circuits.

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