The KY-040 is an inexpensive rotary encoder with a select switch. The Rotary encoder has infinite travel in both clockwise (CW) and anticlockwise (CCW) directions. It essentially means it is ideal for navigating menus on a display or taking inputs such as numbers or text characters. The range of input can be easily defined and mapped in software. The select switch is useful in selecting a menu item or entering a number. These are extensively used as user interface element 3D printers and other electronic devices. The shaft on the encoder can also be fitted with a knob for using it in a product.
The KY-40 has 5 pins as described below. 2 Pins for power, 1 for the select switch and the remaining to are the encoder output pins A and B. The encoder generates 20 pules on each pin during 1 rotation. Pin A leads Pin B in one direction (clockwise) and PIN B leads pin A in Anticlockwise direction. It is recommended to use interrupt pins of the microcontroller to detect rising edge triggers to determine the direction of rotation and the pulse count.
- PCB Size: 3mm x 1.8mm
- 20 pulses per rotation
- Pins broken out.
- + (should be typically connected to 3.3V or 5V depending on the microcontroller)
- SW : Select Switch
- DT (Also refferred as input B)
- CLK (Also refferred as input A)
- Tutorial on using the Encoder as User Input Element with Arduino.