QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: NOVARSEG on November 29, 2020, 01:38:04 am

Title: Quadrature detector code
Post by: NOVARSEG on November 29, 2020, 01:38:04 am
Coding for a quadrature detector. Scroll wheel stuff etc.
The two inputs are PinA and PinB

START:
DO
IF PinA% = 0 then EXIT DO
LOOP
   
DO

IF PinA% = 1 and  PinB% = 0 then scroll% =   1 : GOTO START
IF PinA% = 1 and  PinB% = 1 then scroll% =  - 1 :GOTO START

LOOP

****
scroll% is updated  on the  transition of PinA = 0 to PinA = 1
The code also detects transition of PinA = 1 to PinA = 0