Enacoder problem


Author Message
oh3gdo
Regular Member

Joined: 18/11/2021
Location: Finland
Posts: 47
Posted: 10:53am 04 Nov 2022      

atmega8
Thank you.
When I loaded your program, it doesn't work.
I checked my circuit and found that I have once mode put my wires one down.
When corrected the numbers right PIN 18 and PIN 19, the circuit works find!
Thank you.

' simple encoder reading TassyJim Nov 2022
SetPin GP19, DIN, PULLUP' setup GP19 as an input
SetPin GP18, DIN, PULLUP ' setup GP18 as an input
SetPin GP18, INTH, RInt, PULLUP' setup an interrupt when pin 18 goes high
Do
  ' < main body of the program >
If value <> 0 Then Print "Value", value

EndIf
Loop

Sub RInt ' Interrupt to decode the encoder output
If Pin(gp19) = 1 Then
  Value = Value + 1 ' clockwise rotation
Else
  Value = Value - 1 ' anti clockwise rotation
EndIf
Print "value",Value
End Sub