I need to use a rotary switch with 3 I/Ps to set time in hours and minutes to a microcontroller. 1 input is always connected to ground. The O/P is 2 bit grey code with 36 positions, channel L leads channel R by 90 degrees in the clockwise direction.

When you turn the switch right id like to increment the time and when you turn the switch left to decrement the time. Would anyone be able to help with the code for this rotary encoder? Thanks