Shop OBEX P1 Docs P2 Docs Learn Events
PIC BASIC with PIR sensor — Parallax Forums

PIC BASIC with PIR sensor

ANT1ANT1 Posts: 4
edited 2009-07-29 04:20 in Accessories
Below is my code, I am using a PIC16F84A with PIC BASIC, and am trying to get my PIR to light an LED 2 times, on and off, when it detects an object, any assistance would be much appreciated.


input 5
symbol· PIR············ =5··············· 'Passive infrared sensor, to RB 5

high 1
pause 500
low 1
Main:
IF PIR = 1 THEN PIRdetect

· PAUSE 500
goto main
end


PIRdetect:


·high 1·· 'high RB 1
· pause 500
· LOW 1
·
· pause 500
·
· high 1
· pause 500
· low 1
·
· pause 500
···
goto main


Thank you.


·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-28 22:40
    "IF PIR = 1" probably doesn't do what you want (test the PIR I/O pin). Reread the manual about testing I/O pins. We can't really help you here on programming problems with a PIC or a PIC compiler since this is a Parallax product support forum and this problem isn't really about the PIR sensor.
  • ANT1ANT1 Posts: 4
    edited 2009-07-29 03:48
    Maybe I am hooking it up wrong, do I need a pull down resistor on the output pin of the PIR?



    Any advice for connection would help me to narrow down the problem.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-29 04:20
    You need neither a pullup or pulldown resistor. You operate the PIR sensor off the same power supply as the Stamp or PIC or whatever (3.3V to 5V). The output pin is either a logic low or logic high as described in the PIR sensor datasheet.

    I really don't think the problem is in the connection. I think it's a programming problem.
Sign In or Register to comment.