---
title: Quadrature Encoder Object
description: "[![](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-pressed-1.jpg)](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-pressed-1.jpg)[![](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-1-210x300.jpg)](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-1.jpg) ##### Description These three source code examples interface a quadrature encoder clock, data and button signals to the Propeller 2. The first two…"
url: "https://obex.parallax.com/docs/quick-bytes/propeller-2/quadrature-encoder-object/"
updated: "2026-09-29"
category: Propeller 2
---

# Quadrature Encoder Object

[![](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-pressed-1.jpg)](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-pressed-1.jpg)[![](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-1-210x300.jpg)](/qbi/Quadrature Encoder Object - Parallax_files/Encoder-1.jpg)

##### Description

These three source code examples interface a quadrature encoder clock, data and button signals to the Propeller 2. The first two versions are useful for seeing the internals of the encoder signals, but the third version is a demo with its own encoder object. 

- Rotary_Encoder_Demo1_Archive.zip – read a quadrature encoder with Spin2 and PASM
- Rotary_Encoder_Demo2_Archive.zip – read a quadrature encoder with Spin2 and a more advanced PASM that keeps track of prior positions
- Rotary_Encoder_Demo3_Archive.zip – puts the encoder into its own object

The encoder object and terminal (which may be Parallax Serial Terminal or ANSI-Compliant) are started in this method:

```spin2
pub setup()

      enc.start(ENC_A, ENC_B, ENC_BTN, enc.DETENT, 0, LO, HI)       ' start encoder

      term.tstart(BR_TERM)                                          ' start terminal serial
```

The object used in the third example has a complete encoder configuration for the low and high range and button states. The output from Parallax Serial Terminal looks like this:

[Quadrature Encoder Object for P2 Quick Byte](https://www.youtube.com/embed/UW2mZrQVCrw?feature=oembed)

##### Parts Used

- [P2 Edge Module](https://www.parallax.com/product/p2-edge-module/)
- [P2 Edge Breadboard](https://www.parallax.com/product/p2-edge-module-breadboard/)
- [Rotary Encoder Module with 15×16.5 mm with Knob](https://www.parallax.com/product/27810)

##### Source Code

- [01_quadrature_demo-Archive.zip](/qbi/downloads/01_quadrature_demo-Archive-Date-2022.05.23-Time-06.12.zip)
- [02_quadrature_demo-Archive.zip](/qbi/downloads/02_quadrature_demo-Archive-Date-2022.05.23-Time-06.13.zip)
- [03_jm_quadrature_demo-Archive.zip](/qbi/downloads/03_jm_quadrature_demo-Archive-Date-2022.05.23-Time-06.13.zip)
- [Rotary_Encoder_Demo_Archive.zip](/qbi/downloads/Rotary_Encoder_Demo3_Archive.zip)

##### Programming Language

- [Spin 2](https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit)
- [PASM](https://docs.google.com/spreadsheets/d/1_vJk-Ad569UMwgXTKTdfJkHYHpc1rZwxB-DcIiAZNdk/edit)

##### Tools and Operating System

- PNut_v35c.exe for Windows.

##### Additional Resources

- [Propeller 2 Spin Documentation](https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit)
- [Propeller 2 Live Forum Video: Quadrature Encoder](https://youtu.be/frvBIBsIqMk?list=PLt_MJJ1F_EXa25_TWa4Sdi77daQaxA_ZU)

##### Document Author

- Ken Gracey

##### Source Code Author

- Jon McPhalen
