Hi All,
I found this code on the forum, which works well, that interfaces a rotary encoder and counts and detects direction and outputs to a LCD.
I have found that it sends a dir=0 and dir = 2 for the detection,
question is, could i get it to output a pin high or pin low from this as well?
much help appreciated...I have tried but failed ..
Pete
I found this code on the forum, which works well, that interfaces a rotary encoder and counts and detects direction and outputs to a LCD.
I have found that it sends a dir=0 and dir = 2 for the detection,
question is, could i get it to output a pin high or pin low from this as well?
much help appreciated...I have tried but failed ..
Code:
;Forum Th 271011
#picaxe 18M2
symbol getBits = b0
symbol dir = b1
symbol counter = b3
setint %00000010,%00000010 ,C
main:
do
sertxd("Main loop - Counter=",#b3,13,10)
sertxd("Main loop - dir=",#b1,13,10) 'added to monitor random changes
pause 1000
loop
interrupt:
bit2 = pinC.2: bit1 = pinC.1
getBits = getBits & %000000110
if getBits <> 0 then
dir = bit2 * 2 'direction: if bit2=low then dir=0; if bit2=high then dir=2
counter = counter - 1 + dir
do while getBits <> 0
getBits = pinsC & %000000110
loop
endif
setint %00000010,%00000010 ,C
return
Last edited: