Need some help with the "count" command on BS2
Daniel Brockman
Posts: 6
My next project is a garage door minder,
It monitors my garage door and automatically shuts it after detecting NO motion in the garage after 1 hour.
Im trying to use the "count" command to count the number of times the IR beam has been broken. Im setting it up( the count command) on pin I/O 16.
If the count is "0" then shut the garage after 1 hour
if the count is > or = 1 then I run a sub routine to reset the count to 0 and start the 1 hour process over.
I've looked at the book and can't seem to make heads or tails of the example.
I've figured out how to make the BS2 shut the garage, check to see if indeed its closed, but if I'm working in the garage the IRBeam will be being triggered and I don't want it to close. After I'm in for the night, and "Darn" I forgot to close my garage, the BS2 will detect no motion from the IRBeam, and thus toggle pin 16 high and down goes the garage door.
If you give me the code for this please explain so I can learn. Im very new, and trying my best to grasp.
Thank you guys very much.
Daniel
It monitors my garage door and automatically shuts it after detecting NO motion in the garage after 1 hour.
Im trying to use the "count" command to count the number of times the IR beam has been broken. Im setting it up( the count command) on pin I/O 16.
If the count is "0" then shut the garage after 1 hour
if the count is > or = 1 then I run a sub routine to reset the count to 0 and start the 1 hour process over.
I've looked at the book and can't seem to make heads or tails of the example.
I've figured out how to make the BS2 shut the garage, check to see if indeed its closed, but if I'm working in the garage the IRBeam will be being triggered and I don't want it to close. After I'm in for the night, and "Darn" I forgot to close my garage, the BS2 will detect no motion from the IRBeam, and thus toggle pin 16 high and down goes the garage door.
If you give me the code for this please explain so I can learn. Im very new, and trying my best to grasp.
Thank you guys very much.
Daniel
Comments
I'm sorry, I'll do that now.
I have not done a "syntax" to see if all this is correct, so if you see any other errors, pls scolled me for them
IRBeam Pin 16 'IR Beam from Garage is on Pin 16
Capture CON 1
Cycles VAR Word
Process:
OUTPUT 0
LOW 0
IF IN1 = 1 THEN Timer1
IF IN2 = 1 THEN Timer2
IF IN3 = 1 THEN Timer3
IF IN4 = 1 THEN Timer4
GOTO Process
Timer1: 'Timer 1 is 30 minutes
COUNT (Capture * 1), DEC cycles
IF IRBeam > 1 OR = 1 THEN Reset1
IF IN1 = 0 THEN Process
LOW 0
PAUSE (18000 * 100) ' I hope this sets pause for 30 min
IF IN1 = 0 THEN Process
HIGH 0
PAUSE 1000
LOW 0
PAUSE 30000
GOTO Process
Timer2: ' Timer 2 is 1 hour
IF IN2 = 0 THEN Process
LOW 0
PAUSE (36000 * 100) " 1 hour pause I hope
IF IN2 = 0 THEN Process
HIGH 0
PAUSE 1000
LOW 0
PAUSE 30000
GOTO Process
Timer3: ' Timer 3 is 1.5 hours
IF IN3 = 0 THEN Process
LOW 0
PAUSE (36000 * 100) 'Pause for 1 hour
PAUSE (18000 * 100) 'pause for 1/2 hour
IF IN3 = 0 THEN Process
HIGH 0
PAUSE 1000
LOW 0
PAUSE 30000
GOTO Process
Timer4: 'Timer 4 is set for 2 hours
IF IN4 = 0 THEN Process
LOW 0
PAUSE (36000 * 100) 'pause for 1hour
PAUSE (36000 * 100) 'pause for 1 hour
IF IN4 = 0 THEN Process
HIGH 0
PAUSE 1000
LOW 0
PAUSE 30000
GOTO Process
Reset1: ' rests count on i/o 16 back to a "0" count
COUNT = 0
GOTO Timer1
I have been using the F7 before this on some other small programs I did and it work and the program worked fine. This is the first time using the count command for me. so, If I follow you , then i should go something like,
1: count 16 ( this being the pin im using) duration, variable
correct?
Help -> Basic STamp Help... -> PBASIC Language Reference -> COUNT -> COUNT Example link in the upper right hand corner.
If you are still having problems, post your syntax error free code.
When posting a problem, we need to know what you expect to happen and the steps to reproduce the problem.
There are other ways to do this that are probably more flexible and do not involve the COUNT command per se.