Try this code. (Not tested).
(Problem in your code: you use 'direction_bit' but also 'direct').
Luciano
Code:old_val VAR BYTE new_val VAR BYTE direction_bit VAR BIT enc_counter VAR WORD enc_counter = 10000 new_val = PORTC & %00000011 start: old_val = new_val again: new_val = PORTC & %00000011 IF new_val = old_val Then again direction_bit = old_val.bit0 ^ new_val.bit1 IF direction_bit = 1 Then LCDOut $fe,1,"Last was CW" enc_counter = enc_counter + 1 LCDOut $fe,$c0,DEC enc_counter else LCDOut $fe,1,"Last was CCW" enc_counter = enc_counter - 1 LCDOut $fe,$c0,DEC enc_counter endif GoTo start




Bookmarks