TEP DOWNLOAD CENTER

Project Files of Rotary Encoder Library for Proteus (KY-040 + Arduino)

Libraries Code Projects Simulation
tep://download-terminal rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip ZIP archiveV1.0Verified49 downloadsFree
Rotary Encoder Library for Proteus V1.0: two Arduino UNOs with KY-040 boards, the KY-040 Advance pop-up spinning clockwise at position 56 and the TEP Serial Monitor in its Simple interface counting Position 40 to 52 (CW)
Proteus library · File 1 of 1

Rotary Encoder Library for Proteus V1.0

Rotary Encoder Library for Proteus V1.0 comes as a ZIP archive of 12 files (1.4 MB, 3.0 MB unpacked) holding Proteus library files, simulation model DLLs, a Proteus simulation, an Arduino sketch and compiled HEX firmware.

  • LIBProteus library
  • IDXProteus library index
  • DLLProteus model
  • DSNProteus simulation
  • INOArduino sketch
  • HEXHEX firmware

Description

Looking for the files of Rotary Encoder Library for Proteus (KY-040 + Arduino)? Rotary Encoder Library for Proteus V1.0 is the ZIP package (1.4 MB) you need. It holds the Proteus library files (LIB and IDX), the simulation model (DLL), a ready Proteus simulation, an Arduino sketch and the compiled HEX firmware. Below are the file structure, the README and the installation steps, so you can go from download to a working Proteus simulation in a few minutes.

What this library is

Rotary-Encoder-Library-for-Proteus-v1.0.zip with KY-040 Simple and Advance (TEPKY040.LIB and TEPKY040.DLL), the TEP Serial Monitor and Arduino UNO libraries for Proteus, the two-UNO encoder counter simulation with its HEX file, the demo sketch and a README.

This is version 1.0; older or newer releases, when they exist, are listed in the Development tab.

What is inside the ZIP file

  • ArduinoV3TEP.LIB – Proteus library, 95.6 KB
  • TEPKY040.LIB – Proteus library, 123.8 KB
  • TEPSERIALMON.LIB – Proteus library, 11.1 KB
  • ArduinoV3TEP.IDX – Library index, 830 B
  • TEPKY040.DLL – Simulation model, 379 KB
  • TEPSERIALMON.DLL – Simulation model, 978 KB
  • and 6 more, all listed in the File Structure tab

The archive unpacks to 3.0 MB and carries its own README (README.txt), shown in the README tab above.

How to download

Use the download panel at the top of this page: after the counter (30 seconds for guests, 10 for members) the black button unlocks and the ZIP file comes straight from our content network. If the browser opens it instead of saving, use Save as; extract the whole archive before using anything inside it.

How to install

  • Step 1: Extract the ZIP file with Windows (Extract All), 7-Zip or WinRAR, keeping its folders.
  • Step 2: Close Proteus and copy ArduinoV3TEP.LIB, TEPKY040.LIB and TEPSERIALMON.LIB and ArduinoV3TEP.IDX into its LIBRARY folder (Proteus 8: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY).
  • Step 3: Copy TEPKY040.DLL and TEPSERIALMON.DLL into the MODELS folder next to it, so the part simulates.
  • Step 4: Start Proteus, press P and search for "ArduinoV3TEP"; place and wire it as in the tutorial.
  • Step 5: Open KY040_Encoder_Counter.ino in the Arduino IDE, pick board and port and Verify (Export Compiled Binary gives the HEX).
  • Step 6: In Proteus set the controller's Program File to KY040_Encoder_Counter.hex; on hardware, flash the same file.
  • Step 7: Open KY040-Encoder-Counter-ArduinoUnoV3.pdsprj in Proteus and press Play.

Read the detailed guide

This page is for the files. The full tutorial, Rotary Encoder Library for Proteus (KY-040 + Arduino), explains the circuit and the code step by step and shows the working results and the simulation; read it before you build. Questions about the download or the installation go in the comments below; more Proteus downloads are listed further down this page.

The package is free for personal, educational and research projects; credit The Engineering Projects and link to this page when you share it rather than re-uploading the file.

Read Rotary Encoder Library for Proteus (KY-040 + Arduino)

File Structure

rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip12 files · 5 folders · 3.0 MB unpacked
KY040-TEP-v1.0/12 files · 3.0 MB
Arduino Code/1 file · 8 KB
KY040_Encoder_Counter/1 file · 8 KB
INO KY040_Encoder_Counter.inoArduino sketch 8 KB
Proteus Library Files/4 files · 231.3 KB
IDX ArduinoV3TEP.IDXLibrary index 830 B
LIB ArduinoV3TEP.LIBProteus library 95.6 KB
LIB TEPKY040.LIBProteus library 123.8 KB
LIB TEPSERIALMON.LIBProteus library 11.1 KB
Proteus Model Files/2 files · 1.3 MB
DLL TEPKY040.DLLSimulation model 379 KB
DLL TEPSERIALMON.DLLSimulation model 978 KB
Proteus Simulation/4 files · 1.4 MB
DSN KY040-Encoder-Counter-ArduinoUnoV3.pdsprjProteus simulation 35.7 KB
HEX KY040_Encoder_Counter.hexCompiled HEX file 15.8 KB
DLL TEPKY040.DLLSimulation model 379 KB
DLL TEPSERIALMON.DLLSimulation model 978 KB
TXT README.txtText file 29.7 KB

README

README.txt 376 lines
ROTARY ENCODER KY-040 LIBRARY FOR PROTEUS - V1.0
Designed by The Engineering Projects
www.TheEngineeringProjects.com

IMPORTANT LINKS
Article (read it first - pictures, step by step, every feature explained):
  https://www.theengineeringprojects.com/2026/10/rotary-encoder-library-for-proteus.html
Report a bug or suggest a feature (our forum):
  https://www.theengineeringprojects.com/forum/category/rotary-encoder-proteus-library
The demo uses our TEP Serial Monitor Advance (included) instead of Proteus's
Virtual Terminal - its own article:
  https://www.theengineeringprojects.com/2026/10/serial-monitor-advance-proteus-library.html
Support us (the libraries are free):
  https://www.theengineeringprojects.com/donate

FILE STRUCTURE
KY040-TEP-v1.0/
|-- Proteus Library Files/
|   |-- ArduinoV3TEP.IDX                                0.8 KB   its index -> LIBRARY
|   |-- ArduinoV3TEP.LIB                               95.6 KB   TEP Arduino UNO (demo) -> LIBRARY
|   |-- TEPKY040.LIB                                  123.8 KB   KY-040 Simple + Advance (2 devices) -> LIBRARY
|   |-- TEPSERIALMON.LIB                               11.1 KB   TEP Serial Monitor Advance -> LIBRARY
|-- Proteus Model Files/
|   |-- TEPKY040.DLL                                  379.0 KB   KY-040 model -> MODELS
|   |-- TEPSERIALMON.DLL                              978.0 KB   Serial Monitor model -> MODELS
|-- Proteus Simulation/
|   |-- KY040_Encoder_Counter.hex                      15.8 KB   both UNOs (demo sketch V1.0)
|   |-- KY040-Encoder-Counter-ArduinoUnoV3.pdsprj      35.7 KB   demo: UNO 1 + Simple, UNO 2 + Advance
|   |-- TEPKY040.DLL                                  379.0 KB   copy of the model (runs as is)
|   |-- TEPSERIALMON.DLL                              978.0 KB   copy of the monitor model
|-- Arduino Code/
|   |-- KY040_Encoder_Counter/KY040_Encoder_Counter.ino    8.0 KB   the demo sketch (source of the .hex)
|-- README.txt                                        ~30.8 KB   this file
Total: 2.96 MB (unzipped). The C++ source code of the model is not included.

WHAT IS IT?
A simulation model of the KY-040 rotary encoder module for Proteus 8 - the
black board with an EC11-class mechanical encoder (20 clicks per turn), its
knurled knob with a push switch, the 10 k pull-ups on CLK and DT and the 5-pin
header GND + SW DT CLK. Your Arduino reads it exactly as the real module:
CLK and DT are two switch contacts to GND - HIGH (the pull-ups) when open, LOW
when closed - and they make one full quadrature cycle per click (detent):
  turning clockwise         CLK falls first, then DT, then CLK rises, then DT
  turning counter-clockwise DT falls first, then CLK, then DT rises, then CLK
  at rest (at a detent)     CLK and DT both HIGH
So a sketch reads DT when CLK falls: DT HIGH = clockwise, DT LOW = counter-
clockwise. SW is the push switch to GND: LOW while you press the knob; when
released it floats - R1, its pull-up, is an empty footprint on most boards, so
sketches use INPUT_PULLUP (or set SWPULLUP to 10K in the model).
Like the real contacts, every edge BOUNCES: 1 ms of chatter by default, up to
5 ms (the EN11 / EC11 datasheet maximum) or OFF. Each contact change then
makes 3, 5 or 7 edges (1 to 3 extra pulses; 5.1 edges on average, measured
by the Bounce & debounce tool). A sketch without a debounce counts those
pulses as extra clicks - the model shows you why, and the demo sketch shows
the fix.
You turn the knob yourself: one click CW / CCW, five clicks, or SPIN (keeps
turning), at SLOW 30 RPM (100 ms per click) or FAST 100 RPM (30 ms per click,
the encoder's maximum); PRESS (0.2 s) or HOLD the knob, or click the knob on
the board and hold the mouse button.
While the simulation runs the board is alive: the knob and its red pointer
turn with the shaft (18 deg per click) and look pushed in while SW is LOW;
PWR lights with the supply, CW (green) or CCW (amber) flashes 0.3 s on every
click, SW (blue) lights while SW is LOW - all four are TEP additions: the real
KY-040 has no LED. An "ENCODER VIEW - COUNT" screen above the board shows what
the encoder tells a sketch: a ring of 20 LEDs with the count's position lit,
the count in big digits and the last direction, the CLK / DT / SW levels as
lamps, the quadrature state, the CW / CCW steps, the speed and the bounce.

TWO DEVICES IN ONE LIBRARY (search "KY-040" or "Rotary Encoder" in Pick Devices):
  KY-040 Simple    device KY040TEP     "Rotary Encoder KY-040 - Simple"
                   On-Sheet Panel: the "KY-040 ENCODER SCENE" next to the
                   board - the state banner (AT A DETENT - CLK AND DT BOTH
                   HIGH / TURNING CLOCKWISE - CLK FALLS FIRST, THEN DT /
                   TURNING COUNTER-CLOCKWISE - DT FALLS FIRST, THEN CLK / KNOB
                   PRESSED - SW SHORTED TO GND / NO POWER), the TOP VIEW knob
                   (click its left half: one click CCW, its right half: one
                   click CW) with the quadrature state row (CLK DT 1 1, 0 1,
                   0 0, 1 0), a LOGIC ANALYZER of the last 200 ms (CLK, DT and
                   SW, the contact bounce as pale bursts, a mark per click),
                   POSITION / DIRECTION / RPM / SW and the buttons: TURN THE
                   KNOB (CW x1, CCW x1, CW x5, CCW x5, SPIN CW, SPIN CCW - a
                   SPIN button again stops it), TURN SPEED (SLOW 30 RPM, FAST
                   100 RPM), PUSH BUTTON (PRESS, HOLD - HOLD again releases),
                   CONTACT BOUNCE (BOUNCE ON, BOUNCE OFF) and SET POSITION TO
                   0 (the panel's POSITION readout). The red X in the panel's
                   header closes it, the PANEL button on the board opens it.
  KY-040 Advance   device KY040ADVTEP  "Rotary Encoder KY-040 - Advance"
                   Pop-Up Panel: only the board on the schematic; at Run a TEP
                   pop-up window opens - the same look as the TEP Serial
                   Monitor (move it by its header, resize it, minimise it).
                   The tabs Encoder and Test sit in the header; the gear and ?
                   icons open Settings and Help; the palette icon switches the
                   theme:
                     Encoder   the TOP VIEW knob (click a half to turn one
                               click, the middle to press), THE ENCODER (the
                               state, position, CW / CCW steps, speed, CLK /
                               DT and the quadrature state, the measured lead
                               of the leading contact, the measured time per
                               click, the bounce and the last burst, SW, the
                               last press's LOW time, presses), the turn /
                               speed / bounce / button controls, the last
                               200 ms (CLK / DT / SW, the bounce, the click
                               marks) and the EVENT LOG (power, every turn
                               command, every click with its measured lead,
                               period and bounce edges, every press with its
                               LOW time, the setting changes)
                     Test      four tools measured on the model (see THE TEST
                               TOOLS below): Step count, Bounce & debounce,
                               Direction, Push button
                     Settings  theme (TEP Dark / Light), text size, open at
                               Run, window size - remembered for your Windows
                               user
                     Help      Help & Support like the TEP Serial Monitor:
                               report a bug, suggest a feature, article,
                               guide, updates, donate, website, forum; Copy
                               diagnostics (encoder, pins, board, measured
                               values, events, test results) for a bug report
                   The OPEN PANEL button on the board opens the window again
                   after you close it.
Both devices use the same model (TEPKY040.DLL) and the same properties (the
Advance device has no PANEL property - its window has "open at Run"). On both,
the knob on the board is the push switch: hold the mouse button on it.

WHAT IS IN V1.0
* Two devices: KY-040 Simple (the encoder scene on the sheet, close / open)
  and KY-040 Advance (pop-up window with the encoder page, four test tools,
  settings and help) - see above.
* Board: the black KY-040 drawn clean and bold - the silver EC11 body, the
  knurled knob with a red pointer that turns, R1 (empty) / R2 / R3, the
  mounting holes - with a button row: the PANEL: SHOWN / CLOSED button
  (Simple) or OPEN PANEL (Advance) and a SIMPLE / ADVANCE badge. The LEDs PWR,
  CW, CCW and SW are TEP additions (the real KY-040 has no LED). Above the
  board the animated ENCODER VIEW screen.
* Model: exact quadrature edge times (a click of period P: the leading
  contact closes at P/8, the other at 3P/8, they open at 5P/8 and 7P/8),
  contact bounce bursts on every edge of CLK, DT and SW, SW with or without
  the R1 pull-up, and an event log with MEASURED values: which contact fell
  first and its lead, the time per click, the bounce edges of every click,
  the LOW time of every press.
* The demo: ONE project with two UNOs - UNO 1 with KY-040 Simple, UNO 2 with
  KY-040 Advance - each with the TEP Serial Monitor Advance (U3 = UNO 1,
  U4 = UNO 2, quick buttons).
* The demo sketch counts with INT0 on CLK and a 2 ms debounce, resets the
  count on a press and has the commands HELP, STATUS, RESET and DEBOUNCE ms.
  It prints only when something happens; every line is shorter than 80
  characters.
* The simulation runs light: the panel redraws at most 12.5 times a second
  and only the parts that changed (the logic analyzer included); the pop-up
  repaints at most about 7 times a second.
* No coloured rim around the panel's buttons: the symbol (the panel's look
  before Run) draws every button unselected, and the model paints a clean
  margin under each button, the banner and the readouts before it repaints
  them. The Test page's result tiles show "-" until the tool has measured a
  value.
* This is the first version of this library.
* The model ships as TEPKY040.DLL; its C++ source code is not included.

TEST STATUS
V1.0: verified in Proteus 8.5 on 9 Oct 2026.
  The demo loads and starts cleanly; both monitors print the start lines. On
  U1: CCW x1 "Position: -1 (CCW)", PRESS "Button pressed - reset to 0" /
  "Button released after 0.2 s", CW x5 "Position: 1 (CW)" .. "Position: 5
  (CW)"; SPIN counts on and the logic analyzer shows the quadrature with the
  bounce bursts; HOLD shows KNOB PRESSED - SW SHORTED TO GND with the SW LED
  and the knob pushed in, SPIN CW shows TURNING CLOCKWISE - CLK FALLS FIRST,
  THEN DT. The event log: "Detent CW -> 2: CLK first, 25.000 ms lead, period
  100.000 ms, 20 bounce edges". Step count (one turn): the demo's rule right
  up to 400 RPM (600 RPM: 1 / 1 counted), no debounce wrong at 6 of 6, the
  state table right at all 6, the 10 ms loop right only at 30 RPM (7 / 3 / 0 /
  0 / 0 of 10 phases above), lead 25.000 .. 1.250 ms. Bounce & debounce (1 ms):
  80 transitions (80 bounced), 5.1 edges on average (7 max), longest 1.000 ms,
  right from 1 to 12 ms (the demo's 2 ms right). Direction: CLK / DT lead by
  25.000 ms (90.0 deg), 16 / 16 decoded right by both, 9 reversals, none lost.
  Push button: 5 of 5 seen, 1 long press (1.5 s), 1 double click; LOW 100 /
  200 / 1500 / 80 / 80 ms, and U4 printed 0.1 / 0.2 / 1.5 / 0.1 / 0.1 s. The
  sheet panel: no outline around any button, readable captions, the red X and
  PANEL buttons work. Speed: about 0.62 x real time (56.6 s of simulation in
  91.2 s) with the Step count tool running, the pop-up open and two monitors.
  And 1277 automatic checks on a PC, 0 failed:
  128 on the model alone (the edge times and order for CW and CCW at every
  speed, the rest levels, x1 / x5 / SPIN / stop / speed changes, the bounce
  bursts and their settling, the push switch with and without R1, power, the
  event log with the measured lead / period / bursts / LOW times, and the four
  test tools run as the adapter runs them, with refusals, Stop, power loss);
  313 on the complete Proteus model (properties, CLK / DT / SW edges at the
  exact times, one pending callback, every panel button, the knob halves and
  the board knob, the demo's decoding rule on the pin traces, drawn frames
  without stale pixels - every partial frame compared with a whole repaint -,
  the panel close / open, both devices, the pop-up and all 8 Help links, the
  LEDs, the ENCODER VIEW, ASCII-only sheet text in every state, the event log,
  the tools through the pop-up checked on the pins, the panel captions clear
  of the buttons, the 12.5 Hz redraw of only what changed, no rim of the
  symbol's colour around any button, the banner or the readouts);
  28 with the real demo sketch on TWO UNOs against the complete model (every
  line, the counts = the model's clicks, the bounce miscount with DEBOUNCE 0,
  the press times = the model's measured LOW times, the commands, the Step
  count / Bounce / Push button tools counted by the sketch, nothing printed
  while nothing happens, every line shorter than 80 characters - the longest
  has 69);
  808 on the rendered pop-up and boards (every page fits in TEP Dark and
  Light, at Large text and 150 % DPI; no cut text; no empty band on the test
  pages; every tool's hint lines fit; the result tiles show "-" before a run
  and never a placeholder number).

INSTALLATION (about 2 minutes)
1. Close Proteus. Extract the WHOLE ZIP to a normal folder (e.g. Desktop).
2. Copy everything in "Proteus Library Files" (TEPKY040.LIB with both devices,
   TEPSERIALMON.LIB and the TEP Arduino UNO V3 library ArduinoV3TEP.LIB / .IDX
   used by the demo) to the LIBRARY folder of Proteus, for example:
     C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY
   (on some PCs: C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\
   LIBRARY - use the folder that already holds Proteus's own .LIB files).
3. Copy TEPKY040.DLL and TEPSERIALMON.DLL from "Proteus Model Files" to the
   MODELS folder (...\Proteus 8 Professional\MODELS).
4. If you installed a test copy of this library before: replace its LIB / DLL
   and delete TEPKY040.IDX if there is one in the LIBRARY folder.
5. Start Proteus. In Pick Devices (P) search "KY-040": you get the Simple and
   the Advance device (category Sensors > Rotary Encoders).

RUN THE DEMO
"Proteus Simulation\KY040-Encoder-Counter-ArduinoUnoV3.pdsprj" - keep the .hex
file and the two DLLs beside the project.
  UNO 1 (ARD1): KY-040 Simple (U1), Serial Monitor U3.
  UNO 2 (ARD2): KY-040 Advance (U2), Serial Monitor U4.
  Both run KY040_Encoder_Counter.hex. CLK -> D2, DT -> D3, SW -> D4; the UNO's
  own LED (D13) toggles on every press. (The LED + 220 ohm on A0 comes from the
  demo template; the sketch does not use it.)
  1. Press Run. Both monitor windows open (9600 baud) and so does U2's pop-up.
     U3 and U4 show the three start lines (below). PWR is lit, the ENCODER
     VIEW shows 0 with CLK and DT HIGH and SW open (floating: no R1).
  2. U1: click CW x5 on the panel. The knob turns five clicks (100 ms each),
     CW flashes on every click, the analyzer shows CLK falling before DT with
     the pale bounce bursts, U3 prints "Position: 1 (CW)" .. "Position: 5
     (CW)". CCW x5 counts back to 0. Try SPIN CW / SPIN CCW, FAST 100 RPM,
     the knob's halves in the TOP VIEW, BOUNCE OFF (clean edges) and PRESS
     ("Button pressed - reset to 0", "Button released after 0.2 s"). Hold the
     mouse button on the board's knob for a long press. Close the panel with
     its red X and open it with PANEL: CLOSED on the board.
  3. U3 quick buttons: STATUS, DEBOUNCE 0 (now turn the knob: the bounce adds
     clicks - the count jumps or goes the wrong way), DEBOUNCE 2 (right
     again), HELP. U4: STATUS, DEBOUNCE 5 (for the 5 ms bounce test), RESET,
     HELP.
  4. U2 (Advance): Encoder page - the same controls; watch THE ENCODER card,
     the last 200 ms and the EVENT LOG. Test page: the four tools below.
  5. Close U2's window and open it again with OPEN PANEL on the board.
Closed a monitor window? Click OPEN MONITOR on the monitor part.

WIRING
KY-040 CLK -> D2, DT -> D3, SW -> D4, + -> +5 V, GND -> GND. In the sketch:
pinMode(2, INPUT); pinMode(3, INPUT) (the board's 10 k pull-ups);
pinMode(4, INPUT_PULLUP) (SW has no pull-up on most boards);
attachInterrupt(digitalPinToInterrupt(2), onClkChange, CHANGE). No library is
needed.
Proteus 8.5 note: its AVR model never runs pin-change interrupts (PCINT) - use
INT0 / INT1 (D2 / D3) or read the pins in loop(); encoder libraries that rely
on pin-change interrupts do not count in Proteus.
Serial Monitor RXD <- Arduino D1 (TX), Serial Monitor TXD -> Arduino D0 (RX),
Serial Monitor GND -> ground. RXD2 is not needed: the sketch prints what it
decodes.
Pin order in Proteus: GND + SW DT CLK (left to right, as on the real module
with the header at the bottom and the knob towards you - check your board's
silkscreen).
REAL HARDWARE:
 * Supply 3.3 - 5 V; the contacts carry a few mA (10 mA max). No active
   parts, no LED.
 * 20 clicks (detents) per turn, one full CLK / DT cycle per click, both
   contacts open (HIGH) at a click. Encoders with 30 clicks and 15 pulses per
   turn exist (half a cycle per click) - not modelled.
 * Contact bounce: up to 5 ms on the EN11 datasheet (at 15 RPM; EC11 types
   often 2 ms); 100 RPM is the rated maximum speed.
 * Some clones and tutorials label CLK / DT the other way round: if your count
   runs backwards, swap the two wires (or the pins in the sketch).
 * R1 (the SW pull-up) is missing on most boards: use INPUT_PULLUP.

THE SCENE
  TURN THE KNOB   CW x1 / CCW x1, CW x5 / CCW x5 (queued: opposite clicks
                  cancel), SPIN CW / SPIN CCW (keeps turning; click it again
                  to stop - the click in progress always finishes); or click
                  the TOP VIEW knob's left / right half (one click)
  TURN SPEED      SLOW 30 RPM (100 ms per click: the contact edges 25 ms
                  apart) or FAST 100 RPM (30 ms per click, edges 7.5 ms apart)
                  - a change applies from the next click
  PUSH BUTTON     PRESS (SW LOW for 0.2 s) or HOLD (until you click it again);
                  the knob on the board: pressed while the mouse button is down
  CONTACT BOUNCE  BOUNCE ON (the BOUNCE property, 1 ms when it is 0) or
                  BOUNCE OFF (ideal contacts)
  SET POSITION TO 0  the panel's POSITION readout back to 0 (the sketch keeps
                  its own count - RESET or a press resets it)
While a test tool runs it owns the knob (the scene buttons wait - the
Simulation Log says so once).

THE TEST TOOLS (KY-040 Advance, Test tab) - what they really measure
Every tool runs on the live model. A tool only turns the knob (at the speed it
needs), switches the bounce or presses the switch, and reads the CLK / DT / SW
edges the model really drove - so every number it shows is measured with the
simulation clock. Each tool shows one "Good for:" line and one line on how it
measures. Every tool puts the speed and the bounce back when it ends.
  Step count        Good for: seeing which way of reading the encoder keeps up
                    with fast turning - and why a debounce matters. 5 clicks
                    each way or 20 (one turn) at 30, 60, 100, 200, 400 and 600
                    RPM - CW, then back CCW - with the bounce as set. Four
                    decoders read the same captured edges: the demo sketch's
                    rule (INT0 on CLK, 2 ms debounce, read DT), INT0 with no
                    debounce, a state table (INT0 + INT1, the full Gray code)
                    and loop() reading the pins every 10 ms (at 10 different
                    phases). A grid (OK or the CW / CCW error per speed) and a
                    table with the measured lead. On a PC (1 ms bounce): the
                    demo rule right up to 400 RPM (at 600 RPM the clicks come
                    faster than its 2 ms debounce allows), no debounce wrong
                    at every speed, the state table right at all 6, the 10 ms
                    loop right only at 30 RPM; lead 25.000 ms at 30 RPM, 7.500
                    ms at 100 RPM.
  Bounce & debounce Good for: choosing the debounce time of your sketch - long
                    enough for the chatter, short enough for fast turns. The
                    bounce as set, 1 ms or 5 ms (the EC11 maximum): 10 clicks
                    CW at 30 RPM, 10 CCW at 100 RPM. Every CLK / DT transition
                    with its edges, its length and its shortest pulse; the
                    longest CLK burst zoomed; edges per transition; the demo's
                    rule with a debounce of 0 .. 12 ms (CW / CCW counted). On a
                    PC: 1 ms - 80 transitions, 5.1 edges on average (7 max),
                    longest 1.000 ms, right from 1 to 12 ms (the demo's 2 ms
                    is right); 5 ms - longest 5.000 ms, right from 5 to 8 ms,
                    the demo's 2 ms WRONG (type DEBOUNCE 5 on U4).
  Direction         Good for: checking which way your sketch counts - and that
                    CLK and DT are not swapped in the wiring. 4 clicks CW, 4
                    CCW, then 8 alternating at the speed as set; per click the
                    contact that fell first, its lead (ms and deg), the
                    quadrature states and what the demo rule and a state table
                    decode; the newest CW and CCW click drawn. On a PC (30
                    RPM): CW - CLK leads by 25.000 ms (90.0 deg), CCW - DT
                    leads by 25.000 ms, 16 / 16 decoded right by both, 9
                    reversals, none lost.
  Push button       Good for: setting long-press and double-click times in your
                    sketch - and the bounce its button code must ignore. A
                    click (100 ms), PRESS (200 ms), a long press (1.5 s) and a
                    double click (2 x 80 ms); per press the LOW time, the
                    press and release bounce, the level after the release
                    (floating without R1) and what a sketch with a 30 ms
                    debounce sees (a long press = 1 s or more, a double click =
                    within 0.4 s). On a PC: LOW 100.000 / 200.000 / 1500.000 /
                    80.000 / 80.000 ms, 5 of 5 seen, 1 long press, 1 double
                    click, up to 7 bounce edges in 1.000 ms.
  The tools refuse to start, with the reason, when the encoder has no power or
  another test runs; a running SPIN is stopped first.

THE DEMO SKETCH ON THE SERIAL MONITOR (KY040_Encoder_Counter)
  HELP          the command list (three lines)
  STATUS        the position, the CW / CCW steps, the CLK interrupts, the
                bounce falls ignored, the debounce and the presses (two lines)
  RESET         the position back to 0 (a press does it too)
  DEBOUNCE ms   ignore CLK changes within ms of the last one (0 - 20; 2 at
                start) - DEBOUNCE 0 shows the bounce miscounts
Monitor quick buttons in the demo: U3 STATUS, DEBOUNCE 0, DEBOUNCE 2, HELP;
U4 STATUS, DEBOUNCE 5, RESET, HELP.
The sketch counts in the INT0 interrupt and prints a line only when something
happens; every line is shorter than 80 characters (the TEP Serial Monitor's
Simple interface shows about 80).

EXPECTED MONITOR OUTPUT (U3 and U4)
  KY-040 rotary encoder - turn the knob or press it
  Rotary Encoder Library for Proteus V1.0 - type HELP for the commands.
  Position: 0
Then CW x5 on U1:
  Position: 1 (CW)
  ...
  Position: 5 (CW)
PRESS:
  Button pressed - reset to 0
  Button released after 0.2 s
STATUS (the numbers depend on what you did and on the bounce):
  Position: 0  (CW steps 5, CCW steps 0)
    CLK interrupts 46, bounce ignored 18; debounce 2 ms; presses 1
DEBOUNCE 0, then CW x1 - ONE click, but the bounce is counted too, e.g.:
  Position: 1 (CW)
  Position:
…
Advertisement

Development1 release

  1. V1.0Rotary Encoder Library for Proteus V1.0this page

    V1.0 is the only release in the Download Center so far. When a newer version is published, it appears above with its own download page.

Installation8 steps

From the download to a working project, in order. The steps follow what the package contains.

You will need

  • Proteus Design SuiteProteus 8 or newer (Labcenter), on Windows
  • Arduino IDE1.8 or 2.x, with the board of the tutorial chosen under Tools → Board
  • Any archive toolWindows, macOS and Linux extract ZIP files on their own

Steps

  1. 1

    Extract the archive

    Right-click rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip and choose Extract All (or open it with 7-Zip or WinRAR) into a folder you can find again. Keep its folder structure (KY040-TEP-v1.0) as it is.

  2. 2

    Copy the library files into Proteus

    Move ArduinoV3TEP.LIB, TEPKY040.LIB and TEPSERIALMON.LIB and ArduinoV3TEP.IDX into the LIBRARY folder of your Proteus installation: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY for Proteus 8, or the matching Proteus 7 folder. Older versions keep it under ProgramData\Labcenter Electronics. If Proteus is open, close it first.

  3. 3

    Add the simulation model

    Copy TEPKY040.DLL and TEPSERIALMON.DLL into the MODELS folder next to LIBRARY, so the component can run, not only be drawn.

  4. 4

    Restart Proteus and place the component

    Start Proteus, open a schematic, press P (Pick Devices) and search for the component by the name used in the tutorial. It appears with its pins ready to wire.

  5. 5

    Open the sketch in the Arduino IDE

    Open KY040_Encoder_Counter.ino, select your board and port under Tools, then Verify. Sketch → Export Compiled Binary writes the HEX file a simulation needs.

  6. 6

    Load the HEX file

    In Proteus double-click the microcontroller, set Program File to KY040_Encoder_Counter.hex and run the simulation. For real hardware, flash the same file with your programmer.

  7. 7

    Open the example simulation

    Open KY040-Encoder-Counter-ArduinoUnoV3.pdsprj in Proteus to see the wiring exactly as in the tutorial. Check the controller's Program File path, then press Play.

  8. 8

    Follow the tutorial

    Rotary Encoder Library for Proteus (KY-040 + Arduino) explains every connection and setting in order; keep it open beside the files while you build.

How to add a library in Proteus 8

FAQs9 questionsContact TEP

How do I download Rotary Encoder Library for Proteus V1.0?

Wait for the 30-second guest countdown on this page, then press the download button; the file comes straight from our storage. Members who are logged in skip the wait. If the browser opens the file instead of saving it, use its Save as option. The download link is made for you when the countdown ends and works for 15 minutes; a saved or shared link stops working, so share this page instead.

What is inside the archive?

Rotary Encoder Library for Proteus V1.0 comes as a ZIP archive of 12 files (1.4 MB, 3.0 MB unpacked) holding Proteus library files, simulation model DLLs, a Proteus simulation, an Arduino sketch and compiled HEX firmware. Open the File Structure tab for the full list of 12 files.

What should I do if the download does not start?

Check the browser's download list first; an ad blocker or a company firewall can also hold it back, so try another browser or network. If the file arrives incomplete, download it again. For an installation problem, read the Install tab or tell us in the comments with your software version and the exact error message.

Is this file free?

Yes. Every file in the TEP Download Center is free for learning, personal and student projects. If you share it, link back to this page or the tutorial so others find the latest version.

How do I check that the file arrived complete?

Compare its SHA-256 with the one on this page, 75d9fef69c9ca6857cb6bfd0acfc126c4fe2ec0c88b601cd7f24564b054e9a12. In PowerShell run Get-FileHash "rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip"; on macOS or Linux run shasum -a 256 "rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip". The same value means the file is exactly the one in our storage; a different one means the download broke off, so download it again.

Do I need WinRAR to open the ZIP file?

No. Windows, macOS and Linux open ZIP archives on their own (Extract All, or double-click). WinRAR and 7-Zip work too. Extract the whole archive before using the files.

Where do I put the LIB and IDX files?

Both files go into the LIBRARY folder of your Proteus installation (Proteus 8: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY; Proteus 7 has the same folder under its own name). Restart Proteus afterwards and search for the component with P.

Which Proteus version does the library need?

The tutorial names the Proteus version the library was made and tested with. Most TEP libraries work in Proteus 7 and Proteus 8; if the component does not appear after a restart, check that both the LIB and the IDX file were copied and that Proteus was fully closed while copying.

How do I get the HEX file into the simulation?

Compile the sketch in the Arduino IDE (Sketch → Export Compiled Binary gives you the HEX next to the sketch), then in Proteus double-click the board, set Program File to that HEX and run.

preparing · rotary-encoder-tep-v1-0-22aabf6def4b4e6e98c0fef1f0e004e3.zip
Rating
Your download will be ready shortly
Preparing your download…

Members skip the wait. Log in or join TEP.

  • 49Total downloads
  • 4%Popularity
  • ProteusCategory
  • 0Comments
  • ssyedzainnasirUploaded by
  • 10 Oct 2026Uploaded at
Last 14 days47 downloads
SHA-256 75d9fef69c9ca6857cb6bfd0acfc126c4fe2ec0c88b601cd7f24564b054e9a12
DocumentationRotary Encoder Library for Proteus (KY-040 + Arduino)
Need help with this file? Bug report Ask a question Download problemsGet updates
Advertisement

Comments

0

Join the conversation

Start the conversationAsk a question or share how you used this download.