KY-040 Rotary Encoder Module with Integrated Pushbutton Switch for AVR, PIC, and DIY Electronics
Upgrade your user interfaces with the KY-040 Rotary Encoder Module. Engineered to provide precise incremental positional feedback, this module rotates a full 360 degrees without physical stop limits and features an integrated tactical pushbutton switch when the shaft is depressed. Unlike analog potentiometers, it outputs a digital quadrature gray-scale waveform that tracks both rotational speed and directional orientation. It features pre-wired onboard pull-up resistors, making it a plug-and-play solution for building scroll menus, digital volume knobs, menu selectors, and navigation arrays on Arduino, AVR, PIC, and Raspberry Pi platforms.
₹ 48
₹ 89
| : |
Add FAQ
Detailed Description
The KY-040 Rotary Encoder Module with Pushbutton Switch is a highly versatile human-machine interface (HMI) device engineered for seamless menu navigation and configuration control. Standard analog potentiometers suffer from restricted physical turning angles and are prone to internal resistive wear and environmental dust artifacts. The KY-040 side-steps these issues by employing a contact-based digital indexing array. As the knurled metal D-shaft is rotated, it opens and closes a series of internal electrical contacts, generating a distinct 2-bit quadrature output waveform that indicates both how far it has turned and which direction it is spinning.
Because the shaft has no fixed start or end stops, it can spin continuously through a full 360 degrees indefinitely. The module is engineered with 20 detents (clicks) per revolution, providing distinct tactile feedback that helps users make precise individual parameter selections. Adding to its utility, the module incorporates an internal momentary tactile switch that triggers when the shaft is pressed straight down. This allows you to scroll through complex UI menus and press the knob to select an item, saving valuable panel workspace by combining two control mechanisms into one space-saving footprint.
Key Features and Benefits
-
Continuous 360-Degree Rotation: Free from structural physical stops, allowing users to scroll smoothly through infinite data loops or large software lists.
-
Integrated Clicky Tactile Detents: Delivers clear mechanical clicks at 20 distinct intervals per revolution, giving users responsive physical confirmation for every tick.
-
Dual-Action Pushbutton Functionality: Combines rotational navigation with a momentary select switch in a single mechanical layout, cutting down on control panel clutter.
-
Onboard 10k Pull-up Resistors: Pre-populated with necessary SMD pull-up resistors on the
CLK,DT, andSWsignal traces, protecting digital pins from floating states. -
Universal Hardware Porting: Connects seamlessly to standard 5V or 3.3V logic platforms, communicating effortlessly with AVR, PIC, STM32, Arduino, and Raspberry Pi inputs.
Technical Specifications
| Feature Component | Specification Details |
| Encoder Sensing Architecture | Mechanical Incremental Quadrature Array |
| Logic Supply Voltage Window | 3.3V to 5.0V DC (Direct matching to host microcontroller) |
| Pulses Per Revolution (PPR) | 20 Pulses / 20 Tactile Click Detents per 360° |
| Integrated Switch Type | Momentary Pushbutton (Normally Open contact) |
| Onboard Conditioning Circuit | Built-in 10k Ohm SMD Pull-up Resistors |
| Output Waveform Protocol | Dual-Channel Digital Quadrature Gray Code |
| Rotational Mechanical Lifespan | Minimum 30,000 physical cycle operations |
| Pin Header Configuration | 5-Pin Straight Male Header (≈ 2.54mm pitch spacing) |
How to Program & Wire
Module Pinout Identification:
-
GND (-): Common circuit ground return connection.
-
+ (VCC): Logic supply voltage input (+5V or +3.3V matching host registers).
-
SW: Switched Momentary Pushbutton Output (Pulls LOW when shaft is clicked down).
-
DT: Direction Data Signal line (Pairs with CLK to interpret rotation).
-
CLK: Primary Clock Signal line (Triggers state transitions).
Understanding Directional Logic (Quadrature Decoding):
To determine which direction the shaft is spinning, your microcontroller code must sample both the CLK and DT pins simultaneously.
-
When the encoder is rotated Clockwise, the
CLKpin changes state first, leading theDTpin by a phase shift of 90 degrees. -
When rotated Counter-Clockwise, the internal contact alignment shifts, causing the
DTpin to change state first, leading theCLKpin.
Clockwise Rotation: CLK ──┐ ┌──┐ ┌── Counter-Clockwise: CLK ┌──┐ ┌──┐ ┌
└──┘ └──┘ └──┘ └──┘ └─
DT ┌──┐ ┌── DT ──┐ ┌──┐ ┌──
└──┘ └── └──┘ └──┘
Quick Arduino IDE Integration Example:
-
Connect + to 5V, GND to GND, CLK to Digital Pin 2, and DT to Digital Pin 3 on your board.
-
Flash the following optimized macro sketch to track directional increments in the serial monitor:
#define CLK_PIN 2
#define DT_PIN 3
int lastClkState;
int currentCounter = 0;
void setup() {
pinMode(CLK_PIN, INPUT);
pinMode(DT_PIN, INPUT);
Serial.begin(9600);
lastClkState = digitalRead(CLK_PIN); // Read the initial state of the clock pin
}
void loop() {
int currentClkState = digitalRead(CLK_PIN);
// Check if the encoder has ticked (state changed from HIGH to LOW)
if (currentClkState != lastClkState && currentClkState == LOW) {
// If the DT state is different than the CLK state, the encoder is rotating clockwise
if (digitalRead(DT_PIN) != currentClkState) {
currentCounter++;
} else {
currentCounter--;
}
Serial.print("Position Indicator Counter: ");
Serial.println(currentCounter);
}
lastClkState = currentClkState; // Save current state for next loop pass
}
Applications
-
Digital Volume & Audio Levels: Acts as an infinite volume wheel, audio equalizer tuning knob, and microphone gain control on custom media players.
-
HMI Menu Selection: Serves as the primary navigation control for scrolling through complex configurations on 3D printers, CNC control boxes, and LCD shields.
-
Precision Stepper Positioning: Delivers precise manual jog inputs for micro-stepping linear actuators, motorized microscope stages, and camera rigs.
-
Instrumentation Calibration: Adjusts current limits, timer counts, and frequency settings on digital power supplies, oscillators, and smart laboratory instruments.
Package Includes
-
1 x KY-040 Rotary Encoder Module with Integrated Pushbutton Switch
Shipping & Delivery
-
Free shipping on orders above ₹999 across India
-
Dispatched within 1-3 business days
-
Expected delivery: 3-7 business days depending on location
-
Secure packaging to ensure safe transit of electronic components
0 Reviews For this Product