The cool arduino rotary encoder (coolARE) library is implemented for rotary encoders of type KY-040 including a switch button.
The implementation follows an absoulte minimum.
Do the follwing:
Bake an object:
ARE are( 9, 8, 7 ); // bakes an object; select CLK = PIN 9, DS = PIN 8, and SW = PIN 7
or without using the button:
ARE are( 9, 8 ); // bakes an object; select CLK = PIN 9, and DS = PIN 8
call in arduino's setup method:
are.setup( ); // inits pins and member variables
read the steps up and down in arduino's loop method:
int steps = are.read( ); // .., -2, -1, 0, 1, 2, ..; inits with 0
read the direction:
// this method only works when the are.read( ) is called somewhere!
bool clockwise = are.direction( ); // TRUE clockwise, and FALSE counterwise ..
read the button:
// this method works independently!
bool isPressed = are.button( ); // TRUE when button is pressed, else always false
That's all and far enough.
See the coolARE.ino for a glued example, try running it in arduino IDE. Press CTRL+SHFT+m for the serial monitor; default are 57600 baud to choose. The rotary encoder starts talking to you.
There are stable releases available by cloning or downloading and unzipping. Just put all files in the same directory or the coolARE.h and the coolARE.cpp to your project directory. There's noo need to include a library in arduino IDE or to do something else.
Everything was coded using:
- Rotary Encoders of type KY-040,
- arduino Makefile for automated building,
- atom editor,
- Gnome as window manager,
- and debian GNU/Linux.
have fun :-)
20230518
- updating copyright by year ..
20200416
- release of version 1,
- debugged, working well,
- set up of classes,
- set up of repository.