Markbishop16
Member
Hi
Have an alarm circuit day time buzzer only, night time buzzer and lights. All works great for a single input device. I now have a sensor that provides a pulse each time it is triggered.
I would like the circuit to count if it is triggered two or more times in a 15 second period and then go into alarm.
If no second trigger reset and start again.
Thought I had it with attached script but off the simulator and in real life if input is left on it counts round the loop twice and then goes into alarm.
Any help would be much appreciated, it would be great to be able to increase the input count to 3 etc.
Also if anyone can tell me where to find the "greater than or equal to" and "less than or equal to" signs I would be most grateful
[/CODE]
Have an alarm circuit day time buzzer only, night time buzzer and lights. All works great for a single input device. I now have a sensor that provides a pulse each time it is triggered.
I would like the circuit to count if it is triggered two or more times in a 15 second period and then go into alarm.
If no second trigger reset and start again.
Thought I had it with attached script but off the simulator and in real life if input is left on it counts round the loop twice and then goes into alarm.
Any help would be much appreciated, it would be great to be able to increase the input count to 3 etc.
Also if anyone can tell me where to find the "greater than or equal to" and "less than or equal to" signs I would be most grateful
Code:
[code]
start0:
#Picaxe18M2
let dirsB = %11111111 ; sets B to outputs
let pinsb = %11111111
pause 1000
let pinsb = %00000000 ;start up sequence
pause 1000
let pinsb = %11111111
pause 500
let pinsb = %00000000
pause 500
let pinsb = %11111111
pause 250
let pinsb = %00000000
pause 250
let pinsb = %11111111
pause 100
let pinsb = %00000000
let b7 = pinC.6 ; double knock input
Main:
b7=0 ; clear the input counter
do while b8 < 30 ;15 second input window for two knocks
debug
pause 50
readadc C.0,b2 ; read an analogue value for photo transistor
if pinc.6 = 1 then inc b7 endif; double knock input
pause 100; debounce
if b2>55 and b7 > 1 then gosub buzz ;daytime
if b2=55 and b7 = 1 then gosub lights ;night
if b2 < 55 and b7 > 1 then gosub lights ; nighttime
pause 500 ;loop time
inc b8
loop
b8=0
goto main
buzz: ;on for 5 secs
high b.0, b.2 ; buzzers on
debug
for b5 = 0 to 5
pause 1000
next b5
low b.0, b.2 ;buzzers off
b7 = 0 ;reset counter
b8 = 0 ; reset counter
return
lights:; on for 4 mins
high b.1, b.3,b.0, b.2 ;lights and buzzers on
debug
for b5 = 0 to 3 ; bleeper on time
pause 1000
next b5
low b.0, b.2 ; buzzers off
for b6 = 0 to 5 ; lights on time normally 240
pause 1000
next b6
low b.1, b.3 ;lights off
b7 = 0 ;reset counter
b8 =0 ;reset counter
return