I’m doing a project, a very simple one: it’s a sous vide cooker. The details don’t matter, as in this article we are going to focus on a single component: the KY-040 rotary encoder.
If you are here, you have most likely just bought a KY-040 clone from China, and are looking into how to hook it up to your Arduino. This is a bit of a deviation from the usual highly technical and specific content of this blog, but there’s a good reason for it: I spent 15 minutes googling about this, and all I got was some generic copy-pasted (often clearly stolen) code that mostly - albeit very inefficiently - worked...