0% found this document useful (0 votes)
60 views2 pages

PIR SSENSOR Code and Circuit Diagram

This Arduino code uses a PIR motion sensor connected to analog pin A0 to detect motion. When motion is detected and the sensor reads a value above 200, the LED connected to digital pin 8 is turned on. Otherwise, the LED remains off. The code continuously reads the sensor value, prints it to the serial monitor, and checks if it is above the threshold to control the LED accordingly, with a 500ms delay between readings.

Uploaded by

teekam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views2 pages

PIR SSENSOR Code and Circuit Diagram

This Arduino code uses a PIR motion sensor connected to analog pin A0 to detect motion. When motion is detected and the sensor reads a value above 200, the LED connected to digital pin 8 is turned on. Otherwise, the LED remains off. The code continuously reads the sensor value, prints it to the serial monitor, and checks if it is above the threshold to control the LED accordingly, with a 500ms delay between readings.

Uploaded by

teekam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PIR Sensor Based Motion Detector/Sensor Circuit Diagram & code

Circuit Diagram

Arduino Code
int i=A0;
int l=8;
void setup() {
  pinMode(i,INPUT);
  pinMode(l,OUTPUT);
  Serial.begin(9600);
  
  // put your setup code here, to run once:

void loop() {
  int j=analogRead(A0);
  Serial.println(j);
  delay(500);
  if(j>200)
 {
    digitalWrite(l,HIGH);
 }
  else
 {
     digitalWrite(l,LOW);
    
 }
  // put your main code here, to run repeatedly:

You might also like