Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Rotary Encoder: Examples, Pinouts, and Specs

Image of Rotary Encoder
Cirkit Designer LogoDesign with Rotary Encoder in Cirkit Designer

Introduction

The Alps Alpine STEC12E07 is a high-quality rotary encoder designed to convert the angular position or motion of a shaft into a digital signal. This electromechanical device is widely used in applications requiring precise position sensing, user input control, or rotational feedback. Its compact design and robust performance make it ideal for use in industrial equipment, consumer electronics, and robotics.

Explore Projects Built with Rotary Encoder

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino Mega and Nano-Based Dual Rotary Encoder Controller with AC-DC Power Supply
Image of Dual Encoder (Masters Thesis): A project utilizing Rotary Encoder in a practical application
This circuit features an Arduino Mega 2560 and two Arduino Nano microcontrollers interfacing with two rotary encoders for input. The system is powered by an AC-DC PSU board converting 220V AC to 5V DC, and the microcontrollers communicate with each other via serial connections. The setup is designed for reading rotary encoder inputs and potentially processing or transmitting the data.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Rotary Encoder Interface
Image of encoder: A project utilizing Rotary Encoder in a practical application
This circuit features a rotary encoder (로터리 엔코) interfaced with an Arduino UNO microcontroller. The encoder's outputs A and B are connected to digital pins D2 and D3 for rotation detection, while its push button is connected to D4, potentially for a user input function. The encoder, push button, and a switch are all debounced using resistors, and the microcontroller is set up to receive these signals for processing, although the provided code is empty and does not define specific behaviors.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Mega 2560 Multi-Encoder Interface System
Image of 엔코더: A project utilizing Rotary Encoder in a practical application
This circuit is designed to interface multiple rotary encoders with an Arduino Mega 2560 microcontroller. Each encoder's DT (data) and CLK (clock) pins are connected to specific digital input pins on the Arduino, allowing the microcontroller to read their rotational position changes. The encoders are powered by the Arduino's 5V output and share a common ground, suggesting that the circuit may be used for input devices in a user interface or control system.
Cirkit Designer LogoOpen Project in Cirkit Designer
RP2040 Zero Rotary Encoder Interface with Serial Monitoring
Image of test: A project utilizing Rotary Encoder in a practical application
This circuit features an RP2040 Zero microcontroller interfaced with a rotary encoder. The encoder's clock, data, and switch pins are connected to the microcontroller's GPIO pins 29, 28, and 27, respectively, allowing the microcontroller to read the encoder's state and print it to the serial monitor.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Rotary Encoder

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Dual Encoder (Masters Thesis): A project utilizing Rotary Encoder in a practical application
Arduino Mega and Nano-Based Dual Rotary Encoder Controller with AC-DC Power Supply
This circuit features an Arduino Mega 2560 and two Arduino Nano microcontrollers interfacing with two rotary encoders for input. The system is powered by an AC-DC PSU board converting 220V AC to 5V DC, and the microcontrollers communicate with each other via serial connections. The setup is designed for reading rotary encoder inputs and potentially processing or transmitting the data.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of encoder: A project utilizing Rotary Encoder in a practical application
Arduino UNO-Based Rotary Encoder Interface
This circuit features a rotary encoder (로터리 엔코) interfaced with an Arduino UNO microcontroller. The encoder's outputs A and B are connected to digital pins D2 and D3 for rotation detection, while its push button is connected to D4, potentially for a user input function. The encoder, push button, and a switch are all debounced using resistors, and the microcontroller is set up to receive these signals for processing, although the provided code is empty and does not define specific behaviors.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of 엔코더: A project utilizing Rotary Encoder in a practical application
Arduino Mega 2560 Multi-Encoder Interface System
This circuit is designed to interface multiple rotary encoders with an Arduino Mega 2560 microcontroller. Each encoder's DT (data) and CLK (clock) pins are connected to specific digital input pins on the Arduino, allowing the microcontroller to read their rotational position changes. The encoders are powered by the Arduino's 5V output and share a common ground, suggesting that the circuit may be used for input devices in a user interface or control system.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of test: A project utilizing Rotary Encoder in a practical application
RP2040 Zero Rotary Encoder Interface with Serial Monitoring
This circuit features an RP2040 Zero microcontroller interfaced with a rotary encoder. The encoder's clock, data, and switch pins are connected to the microcontroller's GPIO pins 29, 28, and 27, respectively, allowing the microcontroller to read the encoder's state and print it to the serial monitor.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications

  • Volume and menu control in audio and video equipment
  • Position sensing in industrial machinery
  • User input for microcontroller-based projects
  • Robotics and automation systems
  • Motor speed and direction control

Technical Specifications

The following table outlines the key technical details of the STEC12E07 rotary encoder:

Parameter Specification
Manufacturer Alps Alpine
Part Number STEC12E07
Operating Voltage 5V DC
Maximum Current 10 mA
Output Type Quadrature (2-bit Gray Code)
Rotational Life 30,000 cycles
Detent Positions 30
Pulses per Revolution 15
Operating Temperature -30°C to +85°C
Shaft Length 15 mm
Mounting Style PCB Mount

Pin Configuration and Descriptions

The STEC12E07 rotary encoder has five pins. The table below describes each pin:

Pin Number Pin Name Description
1 GND Ground connection
2 VCC Power supply (typically 5V DC)
3 SW Push-button switch output (active low)
4 DT Data signal for quadrature output
5 CLK Clock signal for quadrature output

Usage Instructions

How to Use the Rotary Encoder in a Circuit

  1. Power Connections: Connect the VCC pin to a 5V DC power source and the GND pin to ground.
  2. Signal Connections: Connect the CLK and DT pins to digital input pins on your microcontroller. These pins provide the quadrature signals for detecting rotation direction and steps.
  3. Push-Button Connection: Connect the SW pin to a digital input pin on your microcontroller. Use a pull-up resistor if necessary, as the switch output is active low.
  4. Debouncing: Implement software or hardware debouncing to ensure reliable signal readings, as mechanical contacts may produce noise.

Important Considerations

  • Debouncing: Rotary encoders can produce noisy signals due to mechanical bouncing. Use software debouncing or external capacitors to filter out noise.
  • Pull-Up Resistors: Ensure pull-up resistors are used for the SW, CLK, and DT pins if your microcontroller does not have internal pull-ups enabled.
  • Signal Timing: Read the CLK and DT signals carefully to determine the direction and number of steps. The quadrature output provides two signals that are 90° out of phase.

Example Code for Arduino UNO

Below is an example Arduino sketch to read the STEC12E07 rotary encoder and detect rotation direction and button presses:

// Pin definitions for the rotary encoder
#define CLK 2  // Clock pin connected to digital pin 2
#define DT 3   // Data pin connected to digital pin 3
#define SW 4   // Switch pin connected to digital pin 4

int lastStateCLK;  // Variable to store the previous state of the CLK pin
int currentStateCLK;  // Variable to store the current state of the CLK pin
int counter = 0;  // Counter to track the encoder position
String direction;  // Variable to store the rotation direction

void setup() {
  pinMode(CLK, INPUT);  // Set CLK pin as input
  pinMode(DT, INPUT);   // Set DT pin as input
  pinMode(SW, INPUT_PULLUP);  // Set SW pin as input with pull-up resistor

  // Read the initial state of the CLK pin
  lastStateCLK = digitalRead(CLK);

  // Initialize serial communication for debugging
  Serial.begin(9600);
}

void loop() {
  // Read the current state of the CLK pin
  currentStateCLK = digitalRead(CLK);

  // If the state of the CLK pin has changed, a step has occurred
  if (currentStateCLK != lastStateCLK) {
    // Check the state of the DT pin to determine the direction
    if (digitalRead(DT) != currentStateCLK) {
      counter++;  // Clockwise rotation
      direction = "CW";
    } else {
      counter--;  // Counterclockwise rotation
      direction = "CCW";
    }

    // Print the direction and counter value to the serial monitor
    Serial.print("Direction: ");
    Serial.print(direction);
    Serial.print(" | Counter: ");
    Serial.println(counter);
  }

  // Update the last state of the CLK pin
  lastStateCLK = currentStateCLK;

  // Check if the push-button is pressed
  if (digitalRead(SW) == LOW) {
    Serial.println("Button Pressed!");
    delay(200);  // Debounce delay
  }
}

Troubleshooting and FAQs

Common Issues

  1. No Signal Detected:

    • Ensure the VCC and GND pins are properly connected.
    • Verify that the CLK and DT pins are connected to the correct microcontroller pins.
    • Check for loose or faulty connections.
  2. Erratic or Noisy Readings:

    • Implement software debouncing in your code.
    • Add a small capacitor (e.g., 0.1 µF) between the CLK and GND pins and between the DT and GND pins to filter noise.
  3. Push-Button Not Working:

    • Verify the SW pin connection and ensure a pull-up resistor is used.
    • Check if the button is physically stuck or damaged.

FAQs

Q: Can I use the STEC12E07 with a 3.3V microcontroller?
A: Yes, the STEC12E07 can work with 3.3V systems, but ensure the signal levels are compatible with your microcontroller.

Q: How do I increase the rotational life of the encoder?
A: Avoid applying excessive force to the shaft and ensure the encoder is mounted securely to prevent mechanical stress.

Q: What is the purpose of the detent positions?
A: Detent positions provide tactile feedback, making it easier to feel discrete steps during rotation.

Q: Can I use this encoder for high-speed applications?
A: The STEC12E07 is suitable for low to moderate-speed applications. For high-speed use, consider encoders designed specifically for such purposes.