Passive Infrared Sensor(PIR) Problem
ANT1
Posts: 4
Problem description:· The code does not appear to be entering the if statement
-I am using PIC BASIC
-I tested the sensor, it gives a HIGH when motion is detected
-The code works, because the LED in Main: lights up for 2 seconds
-I allow for PIR to warm up
Please help
INPUT 3· 'sets RB3 , pin 9 as input
symbol PIR=3· 'PIR sensor connected to pin 9, RB3
symbol LED=2
SYMBOL· IsHigh········· = 1· 'comparison value for if statement of pin status
·
PAUSE 30000 'Allows PIR to warm up
Main:
high LED
pause 2000
low LED
if PIR = IsHigh· THEN loop
pause 1000
goto main
loop:
··· HIGH 2· 'Light LED 2 times 1 second apart if object is detected, pin 8 RB 2
··· pause 250
··· low 2
··· pause 250
··· high 2
··· pause 250
··· low 2
··· pause 500
goto main
Thank you for your time.
-I am using PIC BASIC
-I tested the sensor, it gives a HIGH when motion is detected
-The code works, because the LED in Main: lights up for 2 seconds
-I allow for PIR to warm up
Please help
INPUT 3· 'sets RB3 , pin 9 as input
symbol PIR=3· 'PIR sensor connected to pin 9, RB3
symbol LED=2
SYMBOL· IsHigh········· = 1· 'comparison value for if statement of pin status
·
PAUSE 30000 'Allows PIR to warm up
Main:
high LED
pause 2000
low LED
if PIR = IsHigh· THEN loop
pause 1000
goto main
loop:
··· HIGH 2· 'Light LED 2 times 1 second apart if object is detected, pin 8 RB 2
··· pause 250
··· low 2
··· pause 250
··· high 2
··· pause 250
··· low 2
··· pause 500
goto main
Thank you for your time.
Comments