Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Pir sensor not working
Page 2 of 2 | |||||
Author | Message | ||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Code for flashing LED when motion detected (non interrupt driven). OPTION EXPLICIT CONST PIRLED=1:SETPIN PIRLED,DOUT PIN(PIRLED)=0 'ensure LED off to start with CONST PIRPIN=2: SETPIN PIRPIN,DIN,PULLDOWN 'PROGRAM START DO DO WHILE PIRPIN=0:LOOP ' endless loop while no motion (i.e. PIR input LOW) DO WHILE PIRPIN=1 ' if here then see if motion is still detected PIN(PIRLED)=1 ' LED on PAUSE 200 ' but only briefly PIN(PIRLED)=0 ' before turning LED OFF again PAUSE 200 ' bit more of a delay (so LED can Flash if movement still occurring) LOOP ' see if still moving i.e. PIRPIN=1 LOOP ' if no movement (i.e. PIRPIN=0) - then go back to wait for next movement END For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
rallyman Newbie Joined: 15/02/2017 Location: HungaryPosts: 9 |
here is the new setup: on the left is the arduino panel, power via usb2 from a usb hub. (hub has its own 220V feed) I get the 5V and GRND from the arduino panel. I use the PIC only to get the PIR out and handle it and switch the led if needed. Now it works fine. My code is OPTION EXPLICIT CONST PIRLED=4:SETPIN PIRLED,DOUT CONST PIRPIN=5 SETPIN PIRPIN,INTH,ALERT,PULLDOWN DIM SIGN=0 'PROGRAM START DO PIN(PIRLED)=0 DO WHILE SIGN=0 LOOP MOTIONACTION SIGN=0 LOOP SUB ALERT SIGN=1 END SUB SUB MOTIONACTION PRINT "MOTION DETECTED!" PIN(PIRLED)=1 PAUSE 1000 PIN(PIRLED)=0 END SUB END I will try your code WhiteWizard after a fast lunch |
||||
rallyman Newbie Joined: 15/02/2017 Location: HungaryPosts: 9 |
WhiteWizzard, your code working also fine, many thanks! meantime I changed the arduino panel to a 9V battery as the power source for the led and the pir and still working fine. |
||||
CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 1995 |
That link does nothing to the output (it is always active HI) The link is connected to pin 1 of the BISS001 and that states whether the PIR is re-triggerable or not. With it dragged HI, the device is re-trigerable. This means that if it sees more movement while triggered, the timer is reset to zero - i.e. keep moving and it will always be active and the output HI pulse is "stretched". With it LO, the device will only ever be triggered for the set time and the output will go LO after it expires - if you are still moving, it will immediately trigger HI gain, but you will see a brief LO pulse on the output (between the two triggers). hth h |
||||
Page 2 of 2 |
Print this page |