/NewEncoder

A library that makes coding a rotary encoder a breeze with useful functions

Primary LanguageC++MIT LicenseMIT

GitHub issues Fork Stars License Total Downloads Website

New Encoder

Version 1.0.4

This library is an attempt of obtaining the most properties from rotary encoders as possible. You can get the direction of the last rotation, set the number of steps per turn of your exact model of encoder and even convert the rotation into degrees or radians.

Compatibility

This library was tested on avr, megaavr, sam, samd, nrf52, mbed, mbed_nano, mbed_rp2040 architectures so you should be able to use it without problems.

Releases

To use this library, open the Library Manager in the Arduino IDE, type in "NewEncoder" and install it from there. More on that in the following link

  • 1.0.4

Usage

This library allows an Arduino board to read various parameters from rotary encoders. This devices use two square signals that can be translated into how much the encoder rotates. With this library you can read the rotation of each encoder as well as make usage of the integrated switch button.

The NewEncoder library supports various simultaneous encoders without the need of interrupt pins.

To make use of this library you first need to include the library file and create an instance of an encoder:

#include <NewEncoder.h>

NewEncoder myEncoder;

Circuit

Usually, rotary encoders have 5 pins in total: CLK (or A pin), DATA (or B pin), SW (Switch button), power and ground. The power wire should be connected to the 5V pin on the Arduino board. The ground is connected to any of the ground pins of the Arduino. The CLK, DATA and SW pins can be connected anywhere else in the board and we must declare which pin is connected to which encoder in the begin() function.

  • Schematic (WIP)

Examples

Basic read: Demonstrates the functionality of the methods of the library

Simultaneous encoders: Shows how to handle multiple encoders at the same time

Methods

You can see the list of all functions along with some information about the use cases of each one in this functions explanation file

begin()

Reset()

SetResolution()

Update()

ButtonPressed()

GetSteps()

GetDirection()

GetDirectionName()

Turns()

PercentageOfTurn()

Radians()

Degrees()

Support or Contact

You can always contact me at alexandrocb2013@gmail.com for questions and I'll help you sort it out.

Issues

Find a bug or want to request a new feature? Please let me know by submitting an issue.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details