Hello all,
Update: It is now a Single Wire solution.
there are many pieces of sample code available for using these cheap, Chinese Rotary Encoders, often used for Volume settings or Menu selections.
However, I am under the impression not many are really happy with them, at least I was not.
They either needed many input ports, or using them took both available interrupts, and debouncing was always a PITA.
In my sample code I use just one Analog port and one Digital port, and I use only one interrupt.
This way even a Nano or Mini has several ports free to do something else.
What I think could be an advantage as well, is the fact my code does not need 'polling', so it will not slow down your program.
Basically my 'trick' consists of connecting both the Digital port AND the Analog port to the same input-signal from the Rotary Encoder.
In the new version these functions are combined in just using A0 for both interrupt and signal reading.
The switches inside the encoder are read in a similar way as the 5-button analog keyboard demo.
However, I use the signal, changing when activating the encoder, at the same time to trigger a ISR routine, and to read the voltage at the analog input.
Looking forward to feedback about how to improve this,
Un saludo from Spain,
Satbeginner
P.S. here a link to this type of encoders: http://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20160721235103&SearchText=rotary+encoder
Rotary_Analog.ino (11.3 KB)
Rotary_Encoder_Single_Wire_LK.ino (11.4 KB)