steve24rdg
Member
Hi
I am having trouble making a bit of code to debounce an input switch
could some kind person please give me an example of how to do this please.
I understand that you have to read an input,
put it into a variable,
wait 20ms,
re read the input,
and compare the 2 results.
The problem i have is no matter what i try i get compiler errors or the output that is controlled by the input result does not switch.
symbol switchenable = b1
symbol direction = b0
symbol clockwise = 1
symbol anticlockwise = 0
start0:
main:
input c.4
readadc c.4, direction
pause 20
readadc c.4, switchenable
if switchenable = direction then label3
switchenable = 0
goto main
label3:
select direction
case clockwise low c.1
case anticlockwise high c.1
endselect
goto main
start1:
do
high c.2
pauseus 1
low c.2
pauseus 1
loop
I think the problem lies around the variable that the result is placed into, but I cant see what i need to do
thanks
I am having trouble making a bit of code to debounce an input switch
could some kind person please give me an example of how to do this please.
I understand that you have to read an input,
put it into a variable,
wait 20ms,
re read the input,
and compare the 2 results.
The problem i have is no matter what i try i get compiler errors or the output that is controlled by the input result does not switch.
symbol switchenable = b1
symbol direction = b0
symbol clockwise = 1
symbol anticlockwise = 0
start0:
main:
input c.4
readadc c.4, direction
pause 20
readadc c.4, switchenable
if switchenable = direction then label3
switchenable = 0
goto main
label3:
select direction
case clockwise low c.1
case anticlockwise high c.1
endselect
goto main
start1:
do
high c.2
pauseus 1
low c.2
pauseus 1
loop
I think the problem lies around the variable that the result is placed into, but I cant see what i need to do
thanks