Other [Things] Rotary Encoder for Android Things

Hypnos

Active Member
Licensed User
Longtime User
Dear All,

I would like to make use of the Rotary Encoder on my next project on Android Things running on pi3, am I need a library or anyone can give me some example code on B4A please?

http://guy.carpenter.id.au/gaugette/2013/01/14/rotary-encoder-library-for-the-raspberry-pi/



Currently, I'm using a timer with the following code, but I can't rotate it too fast, any better way ?
B4X:
Sub Timer_Tick

Dim aState As Boolean
aState = PIN17.Value

If aState <> aLastState Then
   If PIN18.Value <> aLastState Then
       R_Value = R_Value +1
   Else
       R_Value = R_Value - 1
   End If
End If

aLastState =aState

End Sub
 
Upvote 0
Top