Enacoder problem


Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6546
Posted: 01:43am 04 Nov 2022      

Using your existing circuit, this program should run
(adapted form code written in 2014)
' simple encoder reading TassyJim Nov 2022
 SETPIN gp19, DIN, PULLUP' setup RB as an input
 SETPIN gp20, INTH, RInt, PULLUP' setup an interrupt when RA goes high
 DO
   ' < main body of the program >
 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
END SUB

I tested without any external pullups and small capacitors (0.1uF) on both switch lines as debounce.

Jim
Edited 2022-11-04 11:45 by TassyJim