Skip to content

Driver for Rotary Encoder on Arduino 101 (and other boards with sufficient IRQs).

License

Notifications You must be signed in to change notification settings

cvonk/arduino-rotary_encoder

Repository files navigation

Rotary Encoder for Arduino-101

Build Status GitHub Discussions GitHub tag (latest by date) GitHub

Using interrupts and allowing multiple instances

This library supports rotary encoders connected to the Arduino/Genuino 101. It should work for other microcontrollers for as long as they can generate the necessary interrupts.

Features:

  • interrupt driven, no polling needed
  • allows for more than one instance
  • ignores spurious signals from encoder
  • lineair or non-lineair mode

Assumptions:

  • The common pins of the rotary encoder are connected to ground, and the remaining pins to GPIO ports

Rotary encoder

Many sketches exist for the Arduino UNO, most of them only supporting a single rotary encoder. I borrowed from one of them, and adapted it for Arduino/Genuino 101.

The challenge was for the interrupt service routines to invoke a C++ Class Member Function. The solution chosen relies on virtual functions and friend classes used as described in the article Interrupts in C++ by Alan Dorfmeyer and Pat Baird.

Rotary encoder

Other Embedded C projects can be found at coertvonk.com.

About

Driver for Rotary Encoder on Arduino 101 (and other boards with sufficient IRQs).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages