Rotary encoder | Software debounce or hardware | Polling or interrupts?

Hi all,

So, I am running the KY-040 encoder with polling and switch with an interrupt. There is noticeable bouncing in the switch, so it's either software debounce with polling or hardware with interrupt.

In general, what is the correct way to work with these encoders? Should it be all the way interrupts, or all the way polling? With interrupts, it seems that writing oled GUI-code would be much simpler? Not having a very large state-machine. While the application is not time sensitive, I guess it is more about convenience.

And yes, I have a read a few topics, and there seems to be people leaning both ways. I am not an expert, or really good with programming anyways, so any views are welcome.

Board I am running is Due, if it makes any difference.

for rotary encoder I allways use interrupt - and keep the ISR as simple as possible

If you take a timestamp (micros) you can see if it is bouncing or not by comparing with previous timestamp.

Use interrupts. It doesn't take a terrible lot of code to start seeing the encoder response slowing with a polled approach.

There are multiple libraries out there just for this purpose, some on this site. I like this one.