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:
use it, don't use
. always, ymmv.


jim
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

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.

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
Post a Comment