Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can build a rotary encoder by attaching a patterned wheel or disk to a shaft and reading its movement with optical or magnetic sensors. For most maker projects that need relative movement and direction, incremental optical quadrature is the clearest starting point: two sensor channels read offset patterns, and the order of their signals reveals which way the shaft turns. Choose an absolute encoder instead when you need a coded angular position rather than a position inferred from accumulated movement.

Choose incremental or absolute encoding first

An encoder converts shaft movement into changing sensor readings. An incremental design reports transitions as the shaft moves; a controller counts them to track relative position. Quadrature adds a second, offset channel so the controller can determine direction. An absolute design reads a coded pattern that represents angular position, rather than relying only on counting transitions since a starting point.

The first decision is therefore what the project needs: relative movement and direction, or a position code. The approaches below differ in target fabrication, sensor spacing, decoding complexity, and how much care the mechanics require.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How quadrature reveals direction

In a quadrature encoder, channels A and B change at different points in the rotation cycle. When B is offset by one quarter-cycle from A, the combination of the two digital signals steps through four states. John Trimble’s 2013 DIY example describes one direction as 00, 01, 11, 10, repeating; rotation in the opposite direction visits the states in reverse order. The controller can count the transitions for movement and use their order for direction.

#1 Best Overall
QSYZAIL 6 Pcs KY-040 Rotary Encoder with Push Button and Knob Cap Compatible with for Arduino
  • Package Include: 6 pcs rotary encoder module and 6 pcs knob caps. The knob is friction‑fit without a set screw. Please press the knob firmly to ensure it stays securely in place. Note: Don't take it off and put it back on repeatedly
  • KY-040 Rotary Encoder: Working voltage: 5 V; One round number of pulse: 20
  • 360 Degree Rotary Encoder: The rotary encoder can count the number of pulses output during forward and reverse rotation by rotating, and the number of rotations is not limited
  • Rotary Encoder Key: Reset to its initial state with the buttons on the rotary encoder, starts counting from 0
  • Versatile Control Solution: Ideal for controlling stepper motors, servo motors, digital potentiometers

A single channel can register transitions, but it cannot by itself distinguish forward from reverse. Two channels provide that direction information, provided the target geometry and sensor placement produce a consistent phase offset.

Compare the four DIY architectures

Architecture How it senses rotation Best fit Main design concern
Transmissive optical A slotted or patterned wheel interrupts light traveling from an emitter to a detector. Two tracks can provide A/B quadrature. A relative-position project where a wheel or strip can be placed between emitter and detector. Slots, tooth widths, sensor gap, and alignment must let the detector distinguish blocked from unblocked light reliably.
Reflective optical Light and dark areas on a disk or strip reflect different amounts of infrared light. Two sensors can provide quadrature. A layout where emitter and detector can face the same side of the target. Contrast and sensor-to-target distance must remain stable; a warped disk can change the gap and vary the signal.
Magnetic quadrature Two Hall sensors read a multipole ring magnet and produce A/B signals. A contactless incremental design that suits a magnetic target and appropriate sensor placement. Pole count, sensor placement, bandwidth, environment, and electrical interface affect suitability; published performance is design-specific.
Absolute optical Several detectors read a coded disk whose pattern represents angular position. A project that needs a position code rather than only accumulated incremental movement. More encoded positions and channels mean a more involved target and decoding scheme; a single project’s resolution is not a general benchmark.

Transmissive optical: the straightforward quadrature build

A slotted disk or wheel passes between an infrared emitter and detector. As the slots and solid sections move through the beam, the detector output changes. For quadrature, use two tracks arranged so their transitions are offset by a quarter-cycle. This architecture makes the relation between target geometry and signal easy to understand, but it depends on the wheel consistently blocking the light where intended.

Rank #2
QSYZAIL 6 Pcs EC11 Rotary Encoder with Push Button 5 Pins 360 Degree Code Switch and Knob Cap Compatible with for Arduino
  • EC11 Rotary Encoder: Number of digits: 20; Number of Pins: 5; Length of Shaft: 20 mm / 0.79 in
  • 360 Degree Rotary Encoder: The rotary encoder can count the number of pulses output during forward and reverse rotation by rotating, and the number of rotations is not limited
  • Rotary Encoder Key: Reset to its initial state with the buttons on the rotary encoder, starts counting from 0
  • Compatible with for: Arduino, Raspberry Pi, ESP32
  • Package Include: 6 pcs rotary encoder module and 6 pcs knob caps

Trimble’s build names a GP1A57HRJ00F photo interrupter in its slotted-wheel attempt. The part name is a component lead, not a claim that a complete encoder kit is included.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reflective optical: no through-beam gap, but gap still matters

A reflective design reads alternating light and dark regions on a disk or strip. The emitter and detector face the target, and two sensors can be positioned to create quadrature. Trimble’s build progression also describes SEN-00241 infrared emitter/collector parts and QRE1113 line-sensor breakouts. Their mention documents the author’s approach; it does not establish current availability.

Rank #3
WMYCONGCONG 5 PCS KY-040 Rotary Encoder Module Brick Sensor Board with 120 PCS Multicolored Breadboard Jumper Wires Ribbon Cables Kit
  • The rotation counts are not limited, designed with continuous 360 degree rotation sensors.(cap included)
  • Working voltage: 5V; Reset to its initial state with the buttons on the rotary encoder, starts counting from 0.
  • Designed with detent and push button switch feature, comes with nuts and washers, suitable for Arduino micro controller use.
  • Jumper wires kit, compaitible with 2.54mm spacing pin headers, great for Arduino PCB project, pc motherboard.
  • Package Content: 5 * KY-040 Rotary Encoder Module + 120 PCS Ribbon Cables Kit(including male to male, male to female, female to female).

Reflective sensing still depends on a repeatable sensor-to-target distance. In the reported setup, signal changed as target distance varied, and disk warping changed that distance. A target that appears to have adequate contrast at one point can therefore produce less consistent readings as it rotates.

Magnetic quadrature: a contactless alternative

A pair of Hall sensors can read a multipole ring magnet to produce incremental A/B quadrature. Texas Instruments’ TIDA-00480 reference design uses a 66-pole ring magnet and reports 132 detections per 360 degrees of rotation, or one detection per 2.7 degrees, for that design. TI also reports more than 20 kHz Hall-sensor bandwidth and 15 microseconds latency for TIDA-00480; these are figures for that particular reference design, not universal magnetic-encoder specifications.

Rank #4
Anmbest 10PCS 20mm 5Pins 360 Degree Rotary Encoder Code Switch Digital Potentiometer with Push Button and Orange Knob Cap DIY Kit for Arduino Raspberry pi
  • Type: Encoder code with Switch; Adjustment method: 360 Degree Rotary; Number of digits: 20 digits; Pins: 5.
  • Shaft Diameter: 6mm/0.24inch; Shaft Length: 20mm/0.79inch.
  • In the forward rotation, the A line phase leads the B line phase; when reversed, the B line phase leads the A line phase. The phase relationship and number of rotations of AB can be identified using a simple digital logic circuit (exclusive OR gate and D flip-flop).
  • According to the timing diagram, it is not rigorously summarized as the falling edge of the clock, A and B are the reversed phase is forward rotation, and the same phase is inverted.
  • Applications: Industrial controls, robotics, photographic lenses, computer input devices such as optomechanical mice and trackballs, controlled stress rheometers, and rotating radar platforms.

TI provides a schematic, bill of materials, and design files for TIDA-00480. The company says its assembled board was developed for testing and performance validation and is not available for sale, so treat it as a technical reference rather than a finished board purchase option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Absolute optical: read a code, not just transitions

An absolute optical disk uses multiple detectors to read a pattern that identifies angular position. Arduino’s 2021 account describes a coded-disk clock project with 60-degree resolution. That figure belongs to the project described there; it is not a general resolution for DIY absolute encoders. More position codes typically call for a suitably designed pattern and a decoder capable of interpreting its detector outputs.

Best Value
Konohan 10 Pcs Rotary Encoder Compatible with Arduino Ec11
  • About encoder code switch: these are continuous rotary encoder switches with switches; They can rotate 60 degree rotation degree; Number of digits: 20; Number of Pins: 5
  • Rotary encoder: the rotary encoder can count forward and backward during the rotation of the output pulse frequency, unlike the rotary potentiometer counting, this kind of rotation counting is not limited; The button on the rotary encoder can be reset to the initial state, that is, counting from 0
  • Specification information: the shaft measures 6 mm/ 0.24 inch in diameter and 20 mm/ 0.79 inch in length; With built-in button switch (press operation
  • Wide range of applications: the rotary encoder push button can be applied for data entry of modern car music players, volume and on/off control or for data selection through LED or LCD display; Apart from that, it is very suitable for use with PIC
  • Package content: you will receive 5 pieces 360 degree rotary encoder code switch push button that compatible with EC11 Digital Potentiometer and 5 pieces knob caps, a nice combination to meet your personal needs
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build an optical quadrature target that reads reliably

The wheel is not merely a mechanical accessory: its geometry sets the transitions the sensors can detect. Trimble reported that his first DIY optical-wheel attempt produced as many as 20 fewer pulses than the expected 180 per revolution, attributing the problem to teeth that were too thin to block infrared reliably. That result describes one 2013 build, not a general performance limit.

  • Make the blocked and open regions distinct. In a transmissive design, teeth or solid sections must block the beam clearly. In a reflective design, light and dark regions must create usable contrast.
  • Keep the target flat and the gap stable. A warped reflective disk changes sensor distance during rotation and can make readings inconsistent.
  • Mount the target concentrically. If the disk wobbles or shifts relative to the shaft, the sensor-to-target relationship changes around a revolution.
  • Set channel phase through geometry. Position the second track or sensor so its signal is one quarter-cycle offset from the first.
  • Secure sensor alignment. The sensors must remain positioned over the intended tracks, with the optical path or reflective sensing face maintained through the full turn.

Wire and check the signal before relying on counts

First observe the A/B states while turning the shaft slowly by hand. Confirm that one direction visits the states in sequence and that reversing direction reverses their order. Then count a full revolution in both directions and compare the readings. State your counting convention: sources may distinguish cycles, pulses, and x1 or x4 decoded positions, so a bare “counts per revolution” figure can be ambiguous.

Trimble’s build report recommends checking for invalid state transitions as a way to notice faults. An illegal transition is a clue, not a diagnosis: excessive speed, a damaged target, or sensor misalignment are among the possible causes described in the source. Check the mechanical target and sensor positioning as well as the speed and signal handling before attributing the symptom to one component.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a matched commercial optical module is the better choice

If fabricating a wheel and matching its geometry to sensors is the part you want to avoid, a purpose-built transmissive module can simplify the optical mechanics. US Digital describes its EM2 as providing digital A and B quadrature outputs with an index channel. Its undated product page lists 2,000 to 10,000 CPR, equivalent to 8,000 to 40,000 PPR, among the product options; these are product specifications, not a DIY target recommendation.

Pair the module with a compatible disk or strip rather than assuming an arbitrary target will work. The EM2 page lists matched target options and accessories, and specifies 5 V operation. Check the target match, voltage, output load requirements, and the meaning of the stated resolution before connecting it to a controller.

Quick Recap

Source notes

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.