Menu
Your Cart

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
₹​80.83
₹​68.50 + 18% GST
All Inclusive, Shipping Calculated at Checkout

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);
 Serial.begin(9600);
 attachInterrupt(digitalPinToInterrupt(CLK),CW_Test,FALLING);
}

void loop() {
  Serial.println(DT);
  Serial.println("
");
  Serial.println(count);
  delay(200);
}

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


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

 

Write a review

Note: HTML is not translated!
Bad Good
Captcha