Rotary encoder code && direction switch code