My own code for reading Rotary Encoder
Code:
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 16/2/2013 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
TRISA = %11111 '
TRISB = %00000000 '8 LEDs.
PORTB=0 '
x VAR Byte '
Aux VAR Byte '
Enc VAR Byte '
x=0 '
Aux=0
Enc=0
aaa:
Aux = Enc '
Enc = (PORTA & 3) ' RA0 RA1 2 bits variable 'ENC'.
If Aux = 2 And Enc = 3 Then x=x+1 '
If Aux = 3 And Enc = 2 Then x=x-1 '
PORTB = x ' 8 LED
goto aaa
End
Bookmarks