This sketch is missing a short description
Pins:
CLK to 2
DT to 3
SW to 4
This was sort of a neat learning experience, since the instructions at https://tkkrlab.nl/wiki/Arduino_KY-040_Rotary_encoder_module weren't very useful.
https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder was a lot more useful. The full rotation encoding appears to occur over 30ms, implying that there's a limit of about 30 ticks per second, but experimentally it seemed that the limit was much lower.
It looks like SW is used as a sort of reset clock, going high then low to indicate that the dial hadn't been turned in several seconds.
Embed This Sketch
Use the following HTML code to embed the sketch code above in your blog or website.
<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:265024" frameborder="0"></iframe>
Embed The Serial Monitor
You can also embed the Serial Monitor section! Just use this HTML code.
<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>