Shop OBEX P1 Docs P2 Docs Learn Events
Passive Infrared Sensor(PIR) Problem — Parallax Forums

Passive Infrared Sensor(PIR) Problem

ANT1ANT1 Posts: 4
edited 2009-08-27 01:57 in Accessories
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.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-08-27 01:57
    This probably isn't the forum for posting other (non-parallax) code, but here is what I see. Assuming "symbol" declares a variable, your if is testing two variables against each other, not and input pin value against a symbol.
Sign In or Register to comment.