53
It is difficult to distinguish between the left turn and right turn when programming. However,
when using an oscilloscope to observe the left turn and right turn of a switch, you will find a
phase difference between the signals of the two output pins as shown below.
It shows that if output 1 and output 2 is high, then the switch rotates clockwise; if output 1 is
high and output 2 is low, then the switch rotates counterclockwise. As a result, during SCM
programming, if output 1 is high, then you can tell whether the rotary encoder turns left or
right as long as you know the state of output 2.
Experimental Procedures
Step 1:
Build the circuit
Rotary Encoder Module SunFounder Uno
CLK -----------------------------------D2
DT ------------------------------------ D3
SW ------------------------------------ D4
+ -------------------------------------- 5V
- ------------------------------------- GND
SunFounder