Function to decode a mechanical rotary encoder. Follow the instructions in the test file to build and run.