{"product_id":"rotary-encoder-module-with-pushbutton-switch-ky-040","title":"KY-040 Rotary Encoder Module with Pushbutton Switch for Arduino, Raspberry Pi, ESP32","description":"\u003ch2\u003e📋 Overview\u003c\/h2\u003e\n\u003cp\u003eThe \u003cstrong\u003eKY-040 Rotary Encoder Module\u003c\/strong\u003e is a 360-degree rotary input device — a control knob — that tells your microcontroller how much the knob has been rotated and which direction it's turning. Unlike a potentiometer, a rotary encoder has no start or end point; it spins continuously in either direction, outputting digital pulses your code can count.\u003c\/p\u003e\n\u003cp\u003eThe module also includes a \u003cstrong\u003ebuilt-in pushbutton switch\u003c\/strong\u003e activated by pressing down on the shaft — perfect for confirming menu selections, toggling modes, or adding a second input without extra components. With on-board 10kΩ pull-up resistors on all signal lines, you can connect it directly to your microcontroller with just jumper wires — no breadboard resistors needed.\u003c\/p\u003e\n\u003chr\u003e\n\u003ch2\u003e⭐ Key Features\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cstrong\u003eContinuous 360° Rotation\u003c\/strong\u003e — No mechanical stops; spins freely in both directions\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003e20 Detents Per Revolution\u003c\/strong\u003e — Tactile clicks at every 18° for precise step-by-step input\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eQuadrature Output (CLK + DT)\u003c\/strong\u003e — Two-channel output for reliable direction detection\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eBuilt-in Pushbutton Switch\u003c\/strong\u003e — Press the shaft to activate a normally-open momentary switch\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eOn-Board Pull-Up Resistors\u003c\/strong\u003e — 10kΩ pull-ups on CLK, DT, and SW lines included on the PCB\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003e5V and 3.3V Compatible\u003c\/strong\u003e — Works with Arduino, Raspberry Pi, ESP32, STM32, and more\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eSimple 5-Pin Interface\u003c\/strong\u003e — CLK, DT, SW, +, GND — connect with standard jumper wires\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003chr\u003e\n\u003ch2\u003e📊 Specifications\u003c\/h2\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eEncoder Type\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003eIncremental rotary encoder\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eOperating Voltage\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003e5V DC (also works with 3.3V)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eDetents Per Revolution\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003e20 (18° per detent)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003ePulses Per Revolution\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003e20\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eRotation\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003eContinuous 360° (no mechanical stops)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003ePushbutton Switch\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003eNormally open, momentary (active LOW)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eOn-Board Pull-Up Resistors\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003e10kΩ on CLK, DT, and SW\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eOutput Signal\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003e2-bit quadrature (Gray code)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cstrong\u003eModule Dimensions\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd\u003eApprox. 30 × 18 × 30 mm (1.18 x 0.71 x 1.18 inches) L × W × H\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003c\/tbody\u003e\n\u003c\/table\u003e\n\u003chr\u003e\n\u003ch2\u003e📦 What's in the Box\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003e1x KY-040 Rotary Encoder Module (with knob shaft)\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cem\u003eJumper wires, Arduino board, and knob cap are not included. Any standard 6mm D-shaft knob will fit.\u003c\/em\u003e\u003c\/p\u003e\n\u003chr\u003e\n\u003ch2\u003e🔌 Compatible With\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eArduino (Uno, Mega, Nano, Leonardo, Due, and compatibles)\u003c\/li\u003e\n\u003cli\u003eRaspberry Pi (all models — use 3.3V logic)\u003c\/li\u003e\n\u003cli\u003eESP32 \/ ESP8266\u003c\/li\u003e\n\u003cli\u003eSTM32, Teensy, and other 3.3V–5V microcontrollers\u003c\/li\u003e\n\u003cli\u003ePIC and AVR microcontrollers\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003chr\u003e\n\u003ch2\u003e🚀 Getting Started\u003c\/h2\u003e\n\u003col\u003e\n\u003cli\u003eConnect CLK → Pin 2, DT → Pin 3, SW → Pin 4, + → 5V, GND → GND on your Arduino\u003c\/li\u003e\n\u003cli\u003eOpen the Arduino IDE and paste the example sketch from the User Guide\u003c\/li\u003e\n\u003cli\u003eUpload the sketch and open the Serial Monitor at 9600 baud\u003c\/li\u003e\n\u003cli\u003eTurn the encoder knob — the Serial Monitor displays direction and position count\u003c\/li\u003e\n\u003cli\u003ePress the shaft down — the Serial Monitor displays \"Button pressed!\"\u003c\/li\u003e\n\u003c\/ol\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u003cstrong\u003e💡 Tip:\u003c\/strong\u003e See our complete \u003cstrong\u003eUser Guide\u003c\/strong\u003e linked below for detailed wiring diagrams, pinout tables, sample code, and troubleshooting tips.\u003c\/p\u003e\n\u003c\/blockquote\u003e\n\u003chr\u003e\n\u003ch2\u003e📌 Pinout\u003c\/h2\u003e\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003ePin\u003c\/th\u003e\n\u003cth\u003eFunction\u003c\/th\u003e\n\u003c\/tr\u003e\n\u003c\/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eCLK\u003c\/td\u003e\n\u003ctd\u003eEncoder Output A (clock signal)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eDT\u003c\/td\u003e\n\u003ctd\u003eEncoder Output B (direction signal)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eSW\u003c\/td\u003e\n\u003ctd\u003ePushbutton switch output (active LOW when pressed)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e+\u003c\/td\u003e\n\u003ctd\u003ePower supply (+5V DC)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eGND\u003c\/td\u003e\n\u003ctd\u003eGround\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003c\/tbody\u003e\n\u003c\/table\u003e\n\u003chr\u003e\n\u003ch2\u003e🎯 Typical Applications\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eMenu navigation and selection on LCD\/OLED displays\u003c\/li\u003e\n\u003cli\u003eVolume and brightness controls\u003c\/li\u003e\n\u003cli\u003eParameter adjustment (set points, thresholds, timer values)\u003c\/li\u003e\n\u003cli\u003eStepper and servo motor speed\/direction control\u003c\/li\u003e\n\u003cli\u003eScrolling through lists or data\u003c\/li\u003e\n\u003cli\u003eCNC and 3D printer manual jog controls\u003c\/li\u003e\n\u003cli\u003eDIY audio equipment (amplifiers, mixers)\u003c\/li\u003e\n\u003cli\u003eRobotics — steering and configuration input\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003chr\u003e\n\u003ch2\u003e⚠️ Important Notes\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eMechanical encoders produce contact bounce — use software debouncing or add \u003ca href=\"https:\/\/envistiamall.com\/products\/0-1uf-100nf-500v-ceramic-disc-capacitors-pack-of-10-25-50-100\" target=\"_blank\" title=\"0.1uF (100nF) 500V Ceramic Disc Capacitors\" rel=\"noopener\"\u003e100nF capacitors\u003c\/a\u003e between CLK\/GND and DT\/GND for clean signals\u003c\/li\u003e\n\u003cli\u003eFor best responsiveness, connect CLK and DT to interrupt-capable pins (Pins 2 and 3 on Arduino Uno)\u003c\/li\u003e\n\u003cli\u003eKeep jumper wires under 20cm (8 inches) to minimize electrical noise\u003c\/li\u003e\n\u003cli\u003eThe module includes pull-up resistors — you generally do not need to enable Arduino's internal pull-ups for CLK and DT\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003chr\u003e\n\u003ch2\u003e📄 Documentation \u0026amp; Resources\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003ca href=\"https:\/\/envistiamall.com\/blogs\/learn\/ky-040-rotary-encoder-module-user-guide\" target=\"_blank\" title=\"KY-040 Rotary Encoder Module with Pushbutton Switch User Guide\" rel=\"noopener\"\u003eKY-040 Rotary Encoder Module User Guide\u003c\/a\u003e — Wiring diagrams, pinout, example code, and troubleshooting\u003c\/li\u003e\n\u003cli\u003e\u003ca href=\"https:\/\/envistiamall.com\/blogs\/learn\/tagged\/sensor-detector-modules\" target=\"_blank\" title=\"All sensor, detector and input module user guides\" rel=\"noopener\"\u003eAll Sensor, Detector and Input Module User Guides\u003c\/a\u003e\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003chr\u003e\n\u003cp\u003e\u003cem\u003eSold and supported by \u003ca href=\"https:\/\/envistiamall.com\"\u003eEnvistia Mall\u003c\/a\u003e. Ships from the USA. For wiring diagrams, sample code, and troubleshooting, see the User Guide. The manufacturer and Envistia LLC (dba Envistia Mall) are not responsible for any damages or losses resulting from the use of this product. Always follow proper electrical safety practices when working with electronic components. Specifications are based on manufacturer data and are subject to change without notice.\u003c\/em\u003e\u003c\/p\u003e","brand":"Envistia","offers":[{"title":"Default Title","offer_id":28453729673,"sku":"EM-ECOMP-0004","price":1.49,"currency_code":"USD","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/1641\/0911\/files\/rotary-encoder-rotation-sensor-module-with-pushbutton-switch-for-arduino-avr-pic-diy-ky-040-943596.jpg?v=1712013937","url":"https:\/\/envistiamall.com\/products\/rotary-encoder-module-with-pushbutton-switch-ky-040","provider":"Envistia Mall","version":"1.0","type":"link"}