public class RotaryEncoder extends Button
A rotary encoders is usually placed at the side which is perpendicular to the shaft. They act as sensors for detecting angle, speed, length, position, and acceleration in automation field.
Example datasheet: Rotary Encoder
Example of use:
|Constructor and Description|
Constructor for a new rotary encoder using specific GPIO pin for sw, dt and clk pins.
|Modifier and Type||Method and Description|
Get the current value of the counter corresponding to the position of the shaft.
Updates the value of the counter used for this rotary encoder.
swPin- GPIO pin corresponding to the push button of the encoder.
dtPin- GPIO pin corresponding to the data signal from the encoder.
clkPin- GPIO pin corresponding to the clock from the encoder.
public void getEncoderTurn()
The counter is used to represent the position of the shaft. If you turn to the right, the counter is incremeted by one for each tick. If you turn to the left, the counter is then decremented by one for each tick.
public int getCounterValue()