0% found this document useful (0 votes)
19 views1 page

Prac 12

This document contains an Arduino code that sets up an infrared sensor and an LED. The code reads the sensor status to detect motion, turning the LED on when motion is detected and off when it ends. It also prints messages to the serial monitor indicating the motion status.

Uploaded by

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

Prac 12

This document contains an Arduino code that sets up an infrared sensor and an LED. The code reads the sensor status to detect motion, turning the LED on when motion is detected and off when it ends. It also prints messages to the serial monitor indicating the motion status.

Uploaded by

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

int IRSensor = 9;

int LED = 5;
void setup()
{
Serial.begin(9600);
Serial.println("Serial Working");
pinMode (IRSensor, INPUT);
pinMode (LED, OUTPUT);
}
void loop()
{
int sensorStatus = digitalRead(IRSensor);
if (sensorStatus == 1)
{
digitalWrite (LED, LOW);
Serial.println("Motion Ended!");
}
else{
digitalWrite (LED, HIGH);
Serial.println("Motion Detected!");
}
}

You might also like