Features:
- Continuous rotary operation
- Integrated push-button switch (push to operate)
- Useful for data input like volume control, power control, and menu navigation
- Ideal for use with PIC or ATMEL microcontrollers
Principle of Work:
A slotted disc connected to the common ground pin (C) interacts with two contact pins (A and B). As the knob is rotated, A and B sequentially make contact with ground, generating quadrature signals 90° out of phase. This allows for determining the rotation direction.

If pin B ≠ A when A changes, the rotation is clockwise.

If pin B = A when A changes, the rotation is counterclockwise.
Pinout of the Module:

Pin Type |
Description |
OutA |
Encoder Pin A |
OutB |
Encoder Pin B |
Switch |
Push-button switch |
GND |
Ground |
Applications:
- Robotic arm controller
- Servo and stepper motor control
- Precise motor movement
Circuit:
Connect sensor ground to GND. Connect outA and outB through 220Ω resistors to VCC, and read their signals at pin 6 and 7 respectively.

Library:
No library is required.
Code:
#define outputA 6
#define outputB 7
int counter = 0;
int aState;
int aLastState;
void setup() {
pinMode (outputA, INPUT);
pinMode (outputB, INPUT);
Serial.begin (9600);
aLastState = digitalRead(outputA);
}
void loop() {
aState = digitalRead(outputA);
if (aState != aLastState) {
if (digitalRead(outputB) != aState) {
counter++;
} else {
counter--;
}
Serial.print("Position: ");
Serial.println(counter);
}
aLastState = aState;
}
Upload the code, open the Serial Monitor, and rotate the encoder to observe the position data. Each full cycle produces 30 counts on this module.
Technical Details:
- Rotary Shaft Length: Approx. 12mm
- Shaft Full Length: Approx. 20mm
- Shaft Diameter: Approx. 6mm
- Size (L x W): Approx. 15 x 11mm
- Output: 2-bit gray code
- Closed Circuit Resistance: 3 ohms max
- Max Rating: 10 mA @ 5 VDC
- Operating Temperature: -30 to 70°C
- Storage Temperature: -40 to 85°C
- Rotational Life: Minimum 30,000 cycles
- Switch Life: Minimum 20,000 cycles
Resources:
Comparisons:
Rotary encoders offer 360° rotation, unlike potentiometers that are limited to ~270°. Potentiometers provide absolute position feedback, while encoders track relative position changes. This module requires external resistors, unlike some pre-assembled modules that integrate them.
Features:
- Continuous rotary operation
- Integrated push-button switch (push to operate)
- Useful for data input like volume control, power control, and menu navigation
- Ideal for use with PIC or ATMEL microcontrollers
Principle of Work:
A slotted disc connected to the common ground pin (C) interacts with two contact pins (A and B). As the knob is rotated, A and B sequentially make contact with ground, generating quadrature signals 90° out of phase. This allows for determining the rotation direction.

If pin B ≠ A when A changes, the rotation is clockwise.

If pin B = A when A changes, the rotation is counterclockwise.
Pinout of the Module:

Pin Type |
Description |
OutA |
Encoder Pin A |
OutB |
Encoder Pin B |
Switch |
Push-button switch |
GND |
Ground |
Applications:
- Robotic arm controller
- Servo and stepper motor control
- Precise motor movement
Circuit:
Connect sensor ground to GND. Connect outA and outB through 220Ω resistors to VCC, and read their signals at pin 6 and 7 respectively.

Library:
No library is required.
Code:
#define outputA 6
#define outputB 7
int counter = 0;
int aState;
int aLastState;
void setup() {
pinMode (outputA, INPUT);
pinMode (outputB, INPUT);
Serial.begin (9600);
aLastState = digitalRead(outputA);
}
void loop() {
aState = digitalRead(outputA);
if (aState != aLastState) {
if (digitalRead(outputB) != aState) {
counter++;
} else {
counter--;
}
Serial.print("Position: ");
Serial.println(counter);
}
aLastState = aState;
}
Upload the code, open the Serial Monitor, and rotate the encoder to observe the position data. Each full cycle produces 30 counts on this module.
Technical Details:
- Rotary Shaft Length: Approx. 12mm
- Shaft Full Length: Approx. 20mm
- Shaft Diameter: Approx. 6mm
- Size (L x W): Approx. 15 x 11mm
- Output: 2-bit gray code
- Closed Circuit Resistance: 3 ohms max
- Max Rating: 10 mA @ 5 VDC
- Operating Temperature: -30 to 70°C
- Storage Temperature: -40 to 85°C
- Rotational Life: Minimum 30,000 cycles
- Switch Life: Minimum 20,000 cycles
Resources:
Comparisons:
Rotary encoders offer 360° rotation, unlike potentiometers that are limited to ~270°. Potentiometers provide absolute position feedback, while encoders track relative position changes. This module requires external resistors, unlike some pre-assembled modules that integrate them.