1 to 8 PCS KY-040 360 Degrees Rotary Encoder Module with Knob Cap 5V Brick Sensor Switch Development Board Module for R3 Board
SPECIFICATIONS
Brand Name: NONE
Choice: yes
Condition: New
High-concerned chemical: none
Origin: Mainland China
Package: SMD
Quantity: 1
Type: Voltage Regulator
is_customized: Yes
KY-040 Rotary Encoder Module 360 Degree 20 Pulse with Knob Cap 5V for Arduino DIY Electronics
Key Features & Benefits
π 360Β° Infinite Rotation: No mechanical stops β longer lifespan.
ποΈ 20 Pulses Per Revolution: High precision with direction detection.
π Built-in Push Button: Press shaft for menu confirmation or reset.
π 5V Compatible: Onboard pullβup resistors and debounce capacitors.
π¨ Knob Cap Included: Red/black cap, comfortable feel.
π§© Plug & Play: 5βpin header (GND, +, SW, DT, CLK).
Product Description
Need intuitive menu control for your Arduino project? KYβ040 rotary encoder module is the perfect choice. 360Β° infinite rotation, 20 pulses per revolution, builtβin push button. Onboard pullβups and debounce caps for clean signals. Includes comfortable knob cap. Perfect for digital volume controls, motor position sensing, Arduino menu navigation.
β‘ Quick Start Guide & Important Tips
πΉ What It Does & What You Need
β
This product does:
Detects rotation direction and angle (incremental encoder)
20 pulses per revolution (20 PPR)
Builtβin push button for click actions
Digital output β direct MCU connection
β This product does NOT: Output analog value, remember position after power loss (incremental only), work directly with 3.3V systems
π§ You will need: Arduino/5V MCU, jumper wires, 5V power supply
π¦ Package includes: KYβ040 Module with Knob Cap Γ (as per SKU)
πΉ Pinout

β οΈ Critical Warnings:
Voltage: 5V only. For 3.3V systems (ESP32), use a level shifter.
Signal decoding: Must decode both CLK and DT to determine direction.
Contact bounce: Add software debouncing for reliable readings.
No absolute position: Code must maintain a counter; position lost on power loss.
πΉ Arduino Example Code
const int clkPin = 4;
const int dtPin = 3;
const int swPin = 2;
volatile int counter = 0;
volatile int lastClkState;
int lastSwState = HIGH;
void setup() {
Serial.begin(9600);
pinMode(clkPin, INPUT_PULLUP);
pinMode(dtPin, INPUT_PULLUP);
pinMode(swPin, INPUT_PULLUP);
lastClkState = digitalRead(clkPin);
attachInterrupt(digitalPinToInterrupt(clkPin), readEncoder, CHANGE);
}
void loop() {
int swState = digitalRead(swPin);
if (swState == LOW && lastSwState == HIGH) {
Serial.println("Button pressed!");
delay(50);
}
lastSwState = swState;
Serial.println(counter);
delay(100);
}
void readEncoder() {
int clkState = digitalRead(clkPin);
if (clkState != lastClkState) {
if (digitalRead(dtPin) != clkState) counter++;
else counter--;
}
lastClkState = clkState;
}
πΉ Common Questions
β Jumpy values when rotating?
Contact bounce β add software debouncing (e.g., small delay or filtering).
β Use with ESP32?
Not directly β 5V signal may damage 3.3V GPIO. Use level shifter.
β Position lost after power cycle?
Normal for incremental encoders. Save counter to EEPROM if needed.
β Knob cap included?
Yes β included and preβinstalled.
Specifications
Encoder Module (KY-040)
Model: KY-040
Voltage: 5V
Resolution: 20 PPR
Rotation: 360Β° infinite
Switch: Push button
Output Signals: CLK, DT, SW
Pins: 5 (GND, +, SW, DT, CLK)
Knob Cap: Included (ABS, ~15Γ16.5mm)
Module Size: ~30Γ19Γ29mm (without knob)
Shaft Length: ~20mm
Compatible: Arduino, 5V systems (level shifter needed for 3.3V)


Note: Manual measurement, allow 1β3mm error. Colors may vary.
- Standard Shipping: Standard Shipping (12β18 Business Days)
- Express Shipping: Expedited Shipping (5β9 Business Days)
- Free Shipping: Orders over $199 qualify automatically
- Tracking: Full tracking number provided for all orders
- Returns: 30-day hassle-free return window
- Condition: Items must be unused and in original packaging
- Refund: Full refund processed within 3-5 business days
- Factory Direct: ISO/TS 16949 certified manufacturer
- Quality: 100% electrical continuity tested before shipment
- Experience: 15+ years in automotive connector industry
- Support: Professional technical support available
You may also like
Blog posts
Title
Subscribe to our emails
Be the first to know about new collections and special offers.