Description
Ky-040 Rotary Encoder Sensor Module With Push Button in pakistan
The KY-040 Rotary Encoder Sensor Module with Push Button is an electronic input module designed to detect rotational movement and direction. Unlike a potentiometer, which provides an absolute analog position, this incremental rotary encoder generates digital signals as its shaft rotates.
It uses two output channels, CLK and DT, to identify rotation direction and movement. The built-in push button provides an additional input when the shaft is pressed, making the module useful for selecting menu options, changing settings, and controlling electronic devices.
The KY-040 is commonly used with Arduino UNO, Arduino Nano, ESP32, and other microcontroller boards. It is suitable for robotics, digital control panels, DIY electronics, and user-interface projects.
digilog.pk+2
Technical Specifications
| Parameter | Details |
|---|---|
| Product Model | KY-040 |
| Sensor Type | Incremental Rotary Encoder |
| Rotation | Continuous 360° |
| Output Channels | CLK and DT |
| Rotation Detection | Clockwise and Counterclockwise |
| Push Button | Built-in momentary switch |
| Operating Voltage | Typically 3.3V–5V DC |
| Cycles Per Revolution | Approximately 20 (variant-dependent) |
| Output Type | Digital |
| Interface | 5-pin header |
| Board Material | PCB |
| Main Controller Compatibility | Arduino, ESP32 and compatible boards |
| Module Dimensions | Approximately 32 × 19 × 30mm (listed variant) |
Specifications are based on the listed KY-040 module. Encoder resolution and pin arrangement may vary between manufacturers.
digilog.pk+2
Key Features
-
Rotational Direction Detection: Identifies clockwise and counterclockwise movement.
-
Incremental Digital Output: Generates digital pulses as the shaft rotates.
-
Built-in Push Button: Provides an additional input for selection and confirmation.
-
Continuous Rotation: Supports 360-degree rotation without fixed end stops.
-
Two-Channel Signal: Uses CLK and DT signals to determine movement and direction.
-
Microcontroller Compatibility: Works with Arduino, ESP32, and other compatible development boards.
-
Compact Design: Easy to integrate into electronic control panels and DIY projects.
-
Simple Interface: Uses five connections for power, rotation signals, and button input.
Applications
-
Arduino menu navigation systems
-
ESP32http://lectroway.org/shop/?s=ESP32&post_type=product control panels
-
Digital volume control
-
Stepper motor position adjustment
-
Servo motor control interfaces
-
Robotics control systems
-
DIY electronic equipment
-
Speed and parameter adjustment
-
Interactive electronics projects
Installation / Setup
The KY-040 module has five pins:
| KY-040 Pin | Arduino UNO Connection |
|---|---|
| CLK | Digital Pin 2 |
| DT | Digital Pin 3 |
| SW | Digital Pin 4 |
| + / VCC | 5V |
| GND | GND |
Basic setup instructions:
-
Connect VCC to the Arduino 5V pin.
-
Connect GND to Arduino GND.
-
Connect CLK to digital pin 2.
-
Connect DT to digital pin 3.
-
Connect SW to digital pin 4.
-
Configure the signal pins as inputs using
INPUT_PULLUPwhere appropriate. -
Upload an Arduino program to detect rotation direction and button presses.
When the knob rotates, the CLK and DT signals change in sequence. The microcontroller compares these signals to determine the direction of rotation. Pressing the knob connects the SW output to GND.
Important: Some KY-040 boards include pull-up resistors on CLK and DT, but the SW pin may require the microcontroller’s internal pull-up resistor.
CircuitLens+2
Precautions
-
Use a suitable 3.3V or 5V supply according to your module version.
-
Check the pin labels before connecting the module.
-
Use software debouncing to avoid unwanted multiple readings.
-
Avoid applying excessive force when pressing or rotating the knob.
-
Do not expose the module to water or excessive dust.
-
Use suitable signal handling when connecting it to 3.3V microcontrollers.
-
Remember that an incremental encoder measures relative movement, not absolute shaft position.
YouTube Tutorial
Watch KY-040 Rotary Encoder Arduino Tutorials
Buy from Electroway Pakistan
Get the KY-040 Rotary Encoder Sensor Module with Push Button from Electroway.org for your Arduino, ESP32, robotics, and electronic control projects.
Explore more sensors, modules, and development boards through the Electroway App.
4. Product Summary
The KY-040 Rotary Encoder Module is an incremental rotary input device featuring clockwise and counterclockwise detection, two digital output channels, and a built-in push button. Its compact design and simple five-pin interface make it suitable for Arduino projects, ESP32 control panels, menu navigation, motor adjustment, and DIY robotics applications.

Reviews
There are no reviews yet.