Using a rotary encoder: simple tutorial


hi all,

thought i'd share code, might de-mystify inards of rotary encoder. it's not intended real-life solution- there libraries , interrupts seems way go. it's more of tutorial can see how 2 outputs vary encoder rotated.

attached is:

  • a snippet ec11 datasheet. shows there 2 detents (detent = click stop) per cycle mine has one.
  • my schematic
  • sketch encoder_v3 uses 2x leds indicate pins' status, , prints a, a, b , b depending on status. have turn between detents see these.
  • sketch encoder_v4 counts cycles, taking account of direction, , prints are.


use it, don't use  8). always, ymmv.





jim

mark2 of encoder sketch attached.

my encoder has push-to-make switch in knob, used double , give 2 independent encoders. seeing pins on encoder , b, re-used them d , e; c middle pin.

if run serial monitor open, you'll see keeps track of knob either pressed or not.



Arduino Forum > Using Arduino > Sensors > Using a rotary encoder: simple tutorial


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support