fwd values : 0, 1, 3, 7, 15, 31, 63, 62, 60, 56, 48, 32
reverse values : 0, 32, 48, 60, 62, 63, 62, 60, 56, 48, 32

I have 2 truth tables with switches to turn on/off for these values.
Now i have a pot and a switch start/stop and a switch fwd/reverse..
Now we should not be able to change the sequence commutation if the pot is not 0 so I did a little code like this :


Code:
Direction VAR bit
direction = 0

Main:

        encoderstate1 = PORTA
        
        GoSub GetADC
        
        If ADRESH = 0 Then 'value of the pot stored in ADRESH
            If ADRESL = 0 Then ''value of the pot stored in ADRESH
                direction = PORTE.1 'switch for direction
            EndIf
        EndIf

if encoderstate = 0  then
'switches turn ON/OFF
elseif encoderstate = 1 then 
'switches turn on OFF
elseif encoderstate = 3 then 
..... etc
endif

goto main
I'm getting desesperate to put all this together with my switches
and my reverse sequence with if then. ifelse isn't working properly (need to have oldstate stored like you told me, Olson no ?)