Bringup
Open the editor
Behavioural mixed-signal modelKY-040 (EC11)encoder_ky040

Rotary encoder KY-040 (with button)

Mechanical incremental encoder, 20 detents per revolution, one full quadrature cycle per detent on CLK/DT (CLK leads when turning clockwise), 10 kΩ pull-ups on the module; SW switches to GND (use INPUT_PULLUP). In the schematic: left half = turn left, right half = turn right, center = press.

GND+SWDTCLK
Schematic symbol

Key data

Category
Modules
Simulation model
Behavioural mixed-signal model
Manufacturer part number
KY-040 (EC11)
Reference prefix
SW
Pins
5
Land pattern
PinHeader_1x05_P2.54mm_Vertical

Simulation model

A behavioural model implements the interface of the chip (registers, protocol, timing) at its pins. The pins are connected to the analog circuit like CMOS pins.

Model
encoder
Supply pins
VCC / GND

Pins 5

PinNameUse
GNDGNDGround pinGround
VCC+Supply pinSupply for the module pull-ups (3.3 or 5 V)
SWSWOutput pinPush button: low when pressed
DTDTOutput pinQuadrature signal B: to an input (interrupt)
CLKCLKOutput pinQuadrature signal A: to an input (interrupt)

Parameters 2

Position (detents)poslive
Default0
Button pressedswlive
Default0

PCB

Connector / off-boardPinHeader_1x05_P2.54mm_Vertical

Rotary encoder KY-040 (with button) as a module on a 5-pin header (GND, +, SW, DT, CLK) – compare the order with your own module