No matter what I do, portb.1 goes high and low.... portb.0 don't change
....
Code:TRISB = 000000 PORTB = 000000 oldState VAR BYTE newState VAR BYTE DIR VAR BIT UP CON 1 DN CON 0 oldstate = (porta & 000111) Main_Loop: gosub Encoder gosub check goto main_loop Check : if dir = up then portb.0 = 1 pause 1000 portb.0 = 0 endif if dir = dn then portb.1 = 1 pause 1000 portb.1 = 0 endif return encoder: portb.5 = 1 pause 100 newState = (porta & 000111) portb.5 = 0 If newState <> oldState THEN ' Changed from last time? Select Case oldState Case 1 If NewState = 4 THEN dir=up If NewState = 2 THEN dir=dn Case 2 If NewState = 4 THEN dir=up If NewState = 1 THEN dir=dn Case 4 If NewState = 1 THEN dir=up If NewState = 2 THEN dir=dn END SELECT oldstate=newstate endif Return


.... portb.0 don't change


Bookmarks