Bounce-Free Rotary Encoder

This article describes a simple routine to interface a rotary encoder to a microprocessor; I’ve chosen the ATtiny85 because it’s the simplest processor you could use for such an application. The main routine that does all the work is just 11 lines of C, but I’ve also written a demonstration program that displays the encoder value on a serial 7-segment display, and the direction of rotation on an LED.


Rotary encoders let you control an analogue value by rotating a knob. They generate a series of digital pulses reflecting the distance you’ve turned the knob, and you can also determine the direction it has been turned.”


Related Content