Can someone help with a counter for an input?
Archiver
Posts: 46,084
I wrote one time and I couldn't get the code to work. I can get the
code to recognize an input but only a high or a low. How can I get
the BS2 to count inputs and then after a certain amount of time,
display something? Thanks, Chris
code to recognize an input but only a high or a low. How can I get
the BS2 to count inputs and then after a certain amount of time,
display something? Thanks, Chris
Comments
Following version is a bit more fleshed out and works for me.
Regards,
Steve
i VAR WORD
counter VAR WORD
this VAR BIT
last VAR BIT
HIGH 4
HIGH 5
again:
counter = 0
FOR i = 0 TO 5000 ' adjust to desired interval
this = IN0
counter = this ^ last * (1 - this) + counter
last = this
NEXT
DEBUG CR, HEX4 OUTS, " ", DEC counter
OUT4 = ~( counter / 3 MAX 1 )
OUT5 = ~( counter / 4 MAX 1 )
GOTO again
christopher41877 wrote:
> I wrote one time and I couldn't get the code to work. I can get the
> code to recognize an input but only a high or a low. How can I get
> the BS2 to count inputs and then after a certain amount of time,
> display something? Thanks, Chris