How to use waitpeq
Here is another spin question. Again apologies if it is stupid.
How to you use waitpeq? Im writing a code that counts the number of times a push button is pressed. the circuit i have is a step down switch so the input pin is high when the switch is open and low when the switch is closed. Here is my code:
obj
pst : "parallax serial terminal"
CON
_clkmode=xtal1+pll16x
_xinfreq=5000000
VAR
long counter
long stack[20]
PUB main
dira[3]~ 'set pin 3 to input
pst.Start(115200) 'start serial terminal
pst.str(String("A" ,13)) 'testing where stuff is going wrong
'cognew(checkbutton,@stack) 'start a cog that matches LED pin 20 to input pin 3
counter:=0
pst.str(String("B",13)) 'testing where stuff is going wrong
repeat
pst.Dec(counter)
pst.newline
waitpeq(0,3,0) 'waits untill pin 3 is in low(0)
counter++
waitpeq(1,3,0) 'waits untill pin 3 is in high(1)
'PUB checkbutton
' dira[3]~
' dira[20]~~
' repeat
' outa[20]:=ina[3]
I have tried variations of this such as using
waitpeq(%000000,3,0)
counter++
waitpeq(%100000,3,0)
but I'm still stumped?
How to you use waitpeq? Im writing a code that counts the number of times a push button is pressed. the circuit i have is a step down switch so the input pin is high when the switch is open and low when the switch is closed. Here is my code:
obj
pst : "parallax serial terminal"
CON
_clkmode=xtal1+pll16x
_xinfreq=5000000
VAR
long counter
long stack[20]
PUB main
dira[3]~ 'set pin 3 to input
pst.Start(115200) 'start serial terminal
pst.str(String("A" ,13)) 'testing where stuff is going wrong
'cognew(checkbutton,@stack) 'start a cog that matches LED pin 20 to input pin 3
counter:=0
pst.str(String("B",13)) 'testing where stuff is going wrong
repeat
pst.Dec(counter)
pst.newline
waitpeq(0,3,0) 'waits untill pin 3 is in low(0)
counter++
waitpeq(1,3,0) 'waits untill pin 3 is in high(1)
'PUB checkbutton
' dira[3]~
' dira[20]~~
' repeat
' outa[20]:=ina[3]
I have tried variations of this such as using
waitpeq(%000000,3,0)
counter++
waitpeq(%100000,3,0)
but I'm still stumped?
Comments