25 thoughts on “Rotary Encoder Tutorial with Arduino Code

  1. yes, or figure out …
    yes, or figure out a way to ‘lock’ the encoder when the power is off. That way you can simply write the last position into the EEPROM, and read it back on power up.? ABsolute encoders can be expensive…

  2. BUT @24:29…. you …
    BUT @24:29…. you said that with incremental? encoderes, you can not know the absolute position of something. In my particular case. I need it but only payed atention to this detail on this part of the video.

    So, what do you recomend to solve this? Absolute encoders?

    bye…

  3. Very? nice …
    Very? nice presentation. I really enjoy this video. The aproach that you used in your code is very good. I am porting it right now to another C compiler because I play with PICs, not the arduino.

    But I have one question. First the scenario: I have a box with water inside. This box have a wheel that spin write (just a line) on a paper the level of the fluid inside.

    So I need to digitalize this box/machine. First I thought about encoders and came here and watch your video. OK…..

    BUT @24:29….

  4. hmmm, I would use …
    hmmm, I would use mills() or micros() to to measure pulse widths to get velocity, and maybe even? average the velocity… you just need to mark the time from mills() and the next transition time, and bingo! you’re done! Glad the code worked for you!

  5. I used your code …
    I used your code with a DC motor with quadrature encoder.

    It works! I get pulses and also implimented some code to get time.

    The problem I’m having is when I try to impliment code to calculate velocity….I get zero result or stops the code from functioning.

    Is there a way to send you my code for some help understanding what? I’m doing wrong?

    Thanks

  6. It’s funny to …
    It’s funny to discover how encoder works by using two multimeters with continuity beeps. You? hear one multimeter after other making beeps in one direction, and the reverse in the other direction.

  7. 2 interrupts are …
    2 interrupts are the limit, but theoretically you could add more to the arduino. the chip supports more. You? also could add pin a of one encoder ti int0 and the pin a of the second encoder to int1, so if int is changes you check pin b on the encoder and then you know in which direction you go. This would also need a debounce circuit.

  8. awesome question!!? …
    awesome question!!? I would make some kind of selection circuit that listens for one of the encoders to rotate, then start a timer to ‘wait’ for that encoder to finish, then resume listening to them all. it would be a fairly complex scheme, guess thats a limitation of the arduino… only 2 interrupts

  9. Hi, very …
    Hi, very informative. What if i need 2 or 3 encoders? How do i write the code for? the interrupts in arduino? Thank you.

  10. Thanks! Very …
    Thanks! Very useful? and really well explained!

    But I think that .01 uF is 103, not 102 🙂

    and by the way, there’s a constant for pi in processing

  11. wow very …
    wow very informative. Its like watching a very interesting lecture. Thanks. Do more? vids =)

  12. haha, I know. …
    haha, I know. sometimes it takes that long for me to get inspired to do anything, or in this case, I was waiting for my shopping cart at sparkfun to get filled up before checking out… always hate spending all that money for shipping on a part that cost? 5 cents… I guess the geiger tube pushed it over

Leave a Reply