-
Notifications
You must be signed in to change notification settings - Fork 0
Arduino sketch demonstrating how to read and process the KY-040 rotary encoder output to interpret them as clockwise and counterclockwise turns.
License
oudesnepelaar/Rotary-KY040-Arduino
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This Arduino sketch allows easy interpretation of the Data/Clock pin values of a KY040 rotary encoder and translates them into practically usable CW and CCW turns. One needs to sample the rotation status in a function and poll the values with a high enough frequency to capture all state changes in the CLK / DT output values. CCW turns are represented by an int value of -1, CW turns by 1, no movement by 0. Because this is not a very reliable way to process the turn data, as the polling will be easily delayed by the other code running in the Arduino sketch main loop, a better way is to use interrupt pins. Using interrupts will guarantee that no changes in the output pins are missed. Check out the Library version of this sketch by the same author to see an example of interrupt usage. Ferrie J Bank, Amsterdam 21 February 2020
About
Arduino sketch demonstrating how to read and process the KY-040 rotary encoder output to interpret them as clockwise and counterclockwise turns.
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published