int IRSensor=9;//connect ir sensor module to arduino pin 9
int LED=13;//conect LED to arduino pin 13
void setup() {
Serial.begin(115200);//nit serila at 115200 baud
Serial.println("Serial working");//test to check if serial is working or not
pinMode(IRSensor, INPUT);//IR Sensor pin INPUT
pinMode(LED, OUTPUT);//LED pin output
// put your setup code here, to run once:
}
void loop() {
int sensorstatus=digitalRead(IRSensor);//set the GPIO as INPUT
if(sensorstatus==1)// check if the pin high or not
{
//if the pin is high turn off the onboard led
digitalWrite(LED, LOW);//LED LOW
Serial.println("Motion ended!");//Pint motion detected! on the serial monitor window
}
//else turn on the onboard LED
digitalWrite(LED, HIGH);//LED high
Serial.println("motion detected");//print motion Ended! on the serial monitor window
}
// put your main code here, to run repeatedly: