BOE and a PIR SENSOR
JRC610
Posts: 11
Can somebody help me? I am new to this and can't get this to work right.
I have a BOE and a PIR Sensor that I am trying to get a LED to go on and off with the High and Low signal from the PIR. The LED will go on with the High but not go off with the Low, it just stays on.
This is what I wrote so far, like I said I am new to this.
' This program displays the current state of the PIR Sensor connected to P0
' on the DEBUG screen. Flashes a LED Connected to P1.
'
[noparse][[/noparse] I/O Description ]
PIR = IN0· ' I/O Pin For PIR Sensor
LED = IN1· 'I/O Pin For LED
'
[noparse][[/noparse]Variables ]
PIR VAR Bit
LED VAR Bit
'
[noparse][[/noparse] Program Code ]
·DO
··LED = IN1
· DEBUG HOME, BIN1· IN0 ' Display Status Of P0 At Home Pos.
· PAUSE 100·· ' Same Delay
· IF (PIR = 0) THEN
··· LOW· 0·· ' Zero means 'off'. Set 'Low' to turn off LED
· ELSE
··· HIGH· 1·· ' 1 means "on". Set 'High' to turn ON LED
· ENDIF
· LOOP······· ' Repeat Forever
The other question that I have is the PIR Sensor supposed to go from low to high even if there is nothing in its view? It puts out a High singal about every 3 seconds for about 3 seconds. Yes it will do it the whole time it is on, Even after the warm up time.
I have a BOE and a PIR Sensor that I am trying to get a LED to go on and off with the High and Low signal from the PIR. The LED will go on with the High but not go off with the Low, it just stays on.
This is what I wrote so far, like I said I am new to this.
' This program displays the current state of the PIR Sensor connected to P0
' on the DEBUG screen. Flashes a LED Connected to P1.
'
[noparse][[/noparse] I/O Description ]
PIR = IN0· ' I/O Pin For PIR Sensor
LED = IN1· 'I/O Pin For LED
'
[noparse][[/noparse]Variables ]
PIR VAR Bit
LED VAR Bit
'
[noparse][[/noparse] Program Code ]
·DO
··LED = IN1
· DEBUG HOME, BIN1· IN0 ' Display Status Of P0 At Home Pos.
· PAUSE 100·· ' Same Delay
· IF (PIR = 0) THEN
··· LOW· 0·· ' Zero means 'off'. Set 'Low' to turn off LED
· ELSE
··· HIGH· 1·· ' 1 means "on". Set 'High' to turn ON LED
· ENDIF
· LOOP······· ' Repeat Forever
The other question that I have is the PIR Sensor supposed to go from low to high even if there is nothing in its view? It puts out a High singal about every 3 seconds for about 3 seconds. Yes it will do it the whole time it is on, Even after the warm up time.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Should LED be an Output?
LOW· 0·· ' Zero means 'off'. Set 'Low' to turn off LED
Your LED is connected to P1, the instructions to turn the LED on and off are as follows
HIGH··1·· '·HIGH means 'set P1 logic 1'. Set 'HIGH' to turn on LED
LOW··1·· '·LOW means 'set P1 logic 0'. Set 'Low' to turn off LED
Jeff T.
' This program displays the current state of the PIR Sensor connected to P15
' on the DEBUG screen. Signal from PIR Sensor Flashes a LED Connected to P1.
'
[noparse][[/noparse] I/O Description ]
PIR = IN15· ' I/O Pin For PIR Sensor
LED = IN1· 'I/O Pin For LED
'
[noparse][[/noparse]Variables ]
PIR VAR Bit
LED VAR Bit
'
[noparse][[/noparse] Program Code ]
DO
· DEBUG HOME, BIN1· IN15·· ' Display Status Of P15 At Home Pos.
· 'PAUSE 100··············· ' Same Delay
· IF IN15 = 0 THEN
··· LOW 1
· ENDIF
· IF IN15 = 1 THEN
··· HIGH 1
··· 'PAUSE 100
· ENDIF
LOOP
'HIGH· 1·· ' HIGH means 'set P1 logic 1'. Set 'HIGH' to turn on LED
'LOW· 1·· ' LOW means 'set P1 logic 0'. Set 'Low' to turn off LED
Ok I got fed up with trying to get it to work. I went out and bought another PIR Sensor. This one works, it does not blink on and off. If it does then it is not working properly. Now I have to figure out how to use a timer to keep a LED lit for 10 min. Is this possible?
Anyway, there are two choices for you: the pause command and the sleep command. The pause command is simple:
However, with the pause command, your BS2 will still consume a relatively high current. The tradeoff is the sleep command. With this command, your units are in seconds, rounded to the nearest multiple of 2.304. However, the sleep command causes a slight flicker every once in a while in the circuit. This is contered by a very low power consumption.