Skip to content

cool arduino rotary encoder library is driving the KY-040 type with button in an absolute minimal way.

License

Notifications You must be signed in to change notification settings

graetz23/coolARE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The cool Arduino Rotary Encoder library

Introduction

The cool arduino rotary encoder (coolARE) library is implemented for rotary encoders of type KY-040 including a switch button.

Implementation

The implementation follows an absoulte minimum.

Usage

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.

Releases

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.

Remarks

Everything was coded using:

have fun :-)

Change Log

20230518

  • updating copyright by year ..

20200416

  • release of version 1,
  • debugged, working well,
  • set up of classes,
  • set up of repository.