Your Cart

We are not operational yet. This site is currently under construction. Please check back after a while. For any queries, write to us at [email protected] 

KY-040 Rotary Encoder Module

KY-040 Rotary Encoder Module
KY-040 Rotary Encoder Module
KY-040 Rotary Encoder Module
KY-040 Rotary Encoder Module
KY-040 Rotary Encoder Module
₹​ 140.42
(₹​ 119.00 + GST)
B2B GST Credit Available

KY-040 Rotary Encoder Module 

This KY-040 Rotary Encoder  based module can be used in variety of rotation encoding functions such as shaft rotation positioning, DSO controles, Digital controlled power supplies, Digital Instruments controls etc. It also has a push switch that can be used to extend functionality of this module.

Pin Out - 

GND -  Common

Power - 5V

SW - Push switch connection

DT - Direction

CLK - Clock

How to use?

Using this rotary encoder is straight forward, we have to monitor both CLK and DT pins simultaneously. Whenever the CLK signal changes state to RISING edge or FALLING edge, DT signal's logical state determines the direction of rotation. Each full 360 degree revolution gives 20 pulses on Clock pin.

From the image above we can deduce that,

At Falling edge of CLOCK if DT is HIGH - it indicates CW rotation, else CCW.

Arduino Sketch

int CLK = 2; // CLK Pin to Pin 2 of Arduino, EXT INT
int DIR = 3; // DT Pin to Pin 3 of Arduino
bool DT; // LOW -> CW, HIGH -> CCW
int count = 0;

void setup() {
 pinMode(DIR, INPUT);

void loop() {

void CW_Test(){
  bool val = digitalRead(DIR);
  if(val == HIGH)
    DT = LOW;
    count = count + 1;
    DT = HIGH;
    count = count-1;

Dimensions - 
PCB Size - 26mm x 18mm
Shaft Diameter - 6mm, D Shaped


Write a review

Please login or register to review

Q. Do you provide Cash on Delivery service?
A. We do not support Cash on delivery. we understand that some of the customers may feel it unsafe to transact on hubtronics website. We assure that your transactions are 100% secured. Major reasons for us not supporting CoD are following.

  • We are not a marketplace platform, we are a single seller webstore. Marketplaces like Amazon and Flipkart have to provide services like CoD to ensure that the customers are safe from the fraudulent sellers. For your order on Hubtronics, we are solely responsible for fulfillment and we make sure that we provide up to the mark service to our customers.
  • We use 3rd party courier services. Unlike Amazon / Flipkart, we can not have our own logistics network and we rely on 3rd party courier services like FedEx, DTDC to deliver your orders. These courier companies charge a good commission amount for CoD orders. The fees charged by courier companies for CoD usually ranges from Rs. 50-80 for each order which makes shipping too costly for small items of values under Rs. 1000. Instead of giving that commission to courier companies, We rather give that price benefit to our customers, who believe in our services.
  • To avoid non-serious customers. We started providing CoD services briefly once. Our experience was quite bad as many people just placed the orders for products they were not actually interested to purchase and they refused to take the delivery. In such cases the parcel is sent back to us by shipping service and we still have to pay courier charges. As we were getting too many such orders, we decided to put a stop to CoD orders.
  • Business is mutual trust. As we are a single seller online store, we understand the consequences of poor quality service. We can not afford to loose your trust. So, give us a chance to gain your trust. #KeepExperimenting!