

The EC11 bare encoder is a rotary encoder that provides incremental position feedback through its A and B outputs. It also features a built-in push-button switch (S1) for additional functionality. This component is widely used in user interfaces for tasks such as adjusting settings, navigating menus, or controlling volume. Its compact design and versatility make it a popular choice for both hobbyist and professional applications.








The EC11 encoder typically has 5 pins. The table below describes each pin:
| Pin Name | Description |
|---|---|
| A | Output signal A (quadrature signal) |
| B | Output signal B (quadrature signal) |
| C (GND) | Common ground for the encoder |
| S1 | Push-button switch signal (normally open) |
| S2 (VCC) | Power supply for the encoder (typically 5V) |
Connect the Power Supply:
Connect the Output Signals:
Connect the Push-Button:
Read the Signals:
The following code demonstrates how to use the EC11 encoder with an Arduino UNO to detect rotation and button presses.
// Pin definitions
const int pinA = 2; // Connect to encoder pin A
const int pinB = 3; // Connect to encoder pin B
const int buttonPin = 4; // Connect to encoder push-button (S1)
// Variables to track encoder state
volatile int encoderPosition = 0;
int lastEncoded = 0;
// Button state
int lastButtonState = HIGH;
void setup() {
pinMode(pinA, INPUT_PULLUP); // Enable pull-up resistor for pin A
pinMode(pinB, INPUT_PULLUP); // Enable pull-up resistor for pin B
pinMode(buttonPin, INPUT_PULLUP); // Enable pull-up resistor for button
// Attach interrupts for encoder pins
attachInterrupt(digitalPinToInterrupt(pinA), updateEncoder, CHANGE);
attachInterrupt(digitalPinToInterrupt(pinB), updateEncoder, CHANGE);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read the button state
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW && lastButtonState == HIGH) {
Serial.println("Button Pressed!");
}
lastButtonState = buttonState;
// Print the encoder position
Serial.print("Encoder Position: ");
Serial.println(encoderPosition);
delay(100); // Small delay for readability
}
void updateEncoder() {
// Read the current state of A and B
int MSB = digitalRead(pinA); // Most significant bit
int LSB = digitalRead(pinB); // Least significant bit
int encoded = (MSB << 1) | LSB; // Combine A and B into a single value
int sum = (lastEncoded << 2) | encoded; // Track state changes
// Determine direction based on state transitions
if (sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) {
encoderPosition++;
} else if (sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) {
encoderPosition--;
}
lastEncoded = encoded; // Update the last encoded value
}
updateEncoder function uses interrupts to detect changes in the A and B signals, ensuring accurate position tracking.loop function, and a message is printed when it is pressed.No Response from the Encoder:
Incorrect Position Readings:
Button Not Detected:
Q: Can I use the EC11 encoder with a 3.3V microcontroller?
A: Yes, but ensure the encoder operates reliably at 3.3V. If not, use a level shifter.
Q: How do I increase the resolution of the encoder?
A: The resolution is fixed at 20 PPR. However, you can use software to detect both rising and falling edges of the A and B signals for higher precision.
Q: What is the lifespan of the EC11 encoder?
A: The EC11 encoder typically has a lifespan of 30,000 to 50,000 cycles, depending on usage conditions.
By following this documentation, you can effectively integrate the EC11 bare encoder into your projects and troubleshoot common issues.