Simple routine for a rotary encoder
Posted: Thu Dec 14, 2017 3:24 pm
Hi
I am trying to experiment with switching a few (say 3 or 4) outputs or LEDs sequentially using a rotary encoder, and although this seems simple, I have not been able to get this to function properly. It may be that the encoder I am using is no good, coupled more likely with my not understanding exactly what to do with respect to reading/writing encoder, checking for changes etc., and the correct sequence for using these component macros. Essentially I want something where if one rotates the encoder clockwise, the first output should switch on. Then say one or two clockwise clicks later, it should switch off and the next output should switch on. This would eventually cycle back to selecting/switching the first output. This process would go in reverse if rotating the encoder counter-clockwise, i.e. outputs would switch in descending order, 4,3,2,1, then back to 4.
I have tried a few different PICs at different frequencies, but I don't think my setup is at fault.
If anyone can give me a few pointers or guidance or sample code to get me going in the right direction, I shall be most grateful.
Cheers
Graham
I am trying to experiment with switching a few (say 3 or 4) outputs or LEDs sequentially using a rotary encoder, and although this seems simple, I have not been able to get this to function properly. It may be that the encoder I am using is no good, coupled more likely with my not understanding exactly what to do with respect to reading/writing encoder, checking for changes etc., and the correct sequence for using these component macros. Essentially I want something where if one rotates the encoder clockwise, the first output should switch on. Then say one or two clockwise clicks later, it should switch off and the next output should switch on. This would eventually cycle back to selecting/switching the first output. This process would go in reverse if rotating the encoder counter-clockwise, i.e. outputs would switch in descending order, 4,3,2,1, then back to 4.
I have tried a few different PICs at different frequencies, but I don't think my setup is at fault.
If anyone can give me a few pointers or guidance or sample code to get me going in the right direction, I shall be most grateful.
Cheers
Graham