danparker61
Member
Hi
I am currently working on a project for automatic security lights prototype. The aim of the project is to turn a light on through a relay when light drops to a threshold. The light should be activated through PIR.
I have interfaced the LDR successfully as I have used the function to readadc and witnessed the value changing with light. Relay working also.
I have had no luck so far with the PIR that I have bought. I thought it would be a case of connecting the digital pin to an input on the microcontroller and writing code that basically says 'if light below threshold and presence then turn light I'm.
Below is an example of the code I have used:
The above code is just one example of my attempts to interface the sensor. The sensor is made by hiletgo.
Any help on interfacing PIR would be greatly appreciated.
I am currently working on a project for automatic security lights prototype. The aim of the project is to turn a light on through a relay when light drops to a threshold. The light should be activated through PIR.
I have interfaced the LDR successfully as I have used the function to readadc and witnessed the value changing with light. Relay working also.
I have had no luck so far with the PIR that I have bought. I thought it would be a case of connecting the digital pin to an input on the microcontroller and writing code that basically says 'if light below threshold and presence then turn light I'm.
Below is an example of the code I have used:
Code:
b2 = c.1
Main:
readadc 1, b2
debug b2
if b2 <140 then gosub night_time
goto main
night_time:
do
low b.4
if pinC.0 = 1 then goto presence_detected
readadc 1, b2
debug b2
if b2 > 140 then gosub daytime
loop
presence_detected:
high b.4
pause 4000
goto night_time
daytime:
low b.4
goto main
Any help on interfacing PIR would be greatly appreciated.