How to use Rotary Encoder with Arduino

Sdílet
Vložit
  • čas přidán 14. 10. 2022
  • My last video was a tutorial on how to use rotary potentiometer with Arduino. In this video I provide tutorial but this time for a different position sensor ... rotary encoder.
    It is quite fascinating that this component looking similar to the rotary potentiometer is actually totally different.
    Hope you would find this tutorial useful.
    Link to the code:
    www.hackster.io/mdraber/using...
    If you like this content and you want to support me in creating similar videos go to my Patreon webpage
    / mariosideas
    Or
    www.paypal.com/cgi-bin/webscr...
  • Věda a technologie

Komentáře • 53

  • @garylarson3751
    @garylarson3751 Před 5 měsíci

    Great Video...Would never have thought of using that kind of logic between the two pins with one interrupt handler.

  • @Vandebilt
    @Vandebilt Před 2 měsíci

    Very good educational explaination. I finally understand how it works. I'm currently building a router lift and I will continue to try to connect a Stepper Driver and Stepper motor to make the rotations work correctly with absoule values (together with momentary push buttons) and fine tune the router bit with a rotary encoder in millimeters which would be displayed on a LCD or OLED screen. Thanks for an excellent video.

  • @youssefmostafa5788
    @youssefmostafa5788 Před 2 měsíci

    Awesome, nice explanation and great way of displaying the code

  • @Majk369
    @Majk369 Před rokem +6

    exactly what ive been looking for. Thumbs up👍

    • @marios_ideas
      @marios_ideas  Před rokem

      My pleasure:) like the video and subscribe to my channal. Also consider supporting it.

  • @kasia2240
    @kasia2240 Před měsícem

    This was the best explanation about Rotary Encoder I have found!

  • @o.z.hamzah1707
    @o.z.hamzah1707 Před 4 měsíci +1

    The skip in the digital count is probably caused by bouncing. A "debounce" circuit using CMOS 4093 Schmitt trigger ICs is better that having capacitors to ground - of course, this adds a layer of complexity, but it's doable. I am trying to use your Arduino code with a linear encoder (home-built) rather than a rotary switch for my application. Great easy to follow video and super graphics. Thanks.

  • @bahaajobs
    @bahaajobs Před 7 měsíci

    This is very informative, thank you so much for the video and explanation

  • @mans4104
    @mans4104 Před rokem +2

    The best explanation ever.👍

    • @marios_ideas
      @marios_ideas  Před rokem

      Thanks:) Please give video a like if you enjoyed it

  • @josephgitau280
    @josephgitau280 Před rokem +1

    good explanation bro. ive found it easy than ever

    • @marios_ideas
      @marios_ideas  Před rokem

      Thanks:) Give this video a like then:) Also If you want to see future content like this subscribe and set the neotification not to miss my upcoming videos. There are also ways you can support my channel if you choose to:)

  • @souley_garage
    @souley_garage Před 11 měsíci +7

    Thanks for this video and explanation. The « hesitation » you can see from « falling » trigger mode might be induced by some electrical rebound when contacts are opened/closed. Put a small 10nF between GND and CLK and GND and DT it should solve it :)

  • @kvnl1037
    @kvnl1037 Před 11 měsíci +1

    Useful help !

  • @duanebeyer950
    @duanebeyer950 Před rokem +7

    I found this on Google. "FALLING triggers an interrupt when the signal changes from HIGH to LOW. LOW fires the interrupt for the ENTIRE time the signal remains LOW. So, if your ISR returns while the signal is LOW, the ISR will immediately be called again, after executing only a single instruction back in the foreground task."
    I think what it is saying is with falling, if you have a bounce issue, it may false trigger, but if you force it to "LOW" then the bounce will be ignored. I believe that is what they are saying.
    UPDATE: Actually, after reading this and some other stuff a few more times, I think I have it wrong. So I am in the same place as you, not really sure why LOW is working better in this situation.

    • @marios_ideas
      @marios_ideas  Před rokem +1

      EXACTLY:) I was digging myself and couldn't find reasonable answer

    • @gs051233
      @gs051233 Před 8 měsíci +1

      I think the ISR execution condition of >5ms since last interrupt makes the LOW mode work. This is because when the signal is LOW, the interrupts fires with the clock frequency, which is much faster than 5ms. Therefore, when not turning, ISR is not doing anything despite being fired all the time when the signal pin is low. When the signal pin is high, ISR is not fired anyway, so when rotating and passing from high to low, the >5ms execution time is fulfilled.

  • @francoisdastardly4405
    @francoisdastardly4405 Před 5 měsíci

    Absolutely perfect explanation ❤❤

  • @Anton-wc7lb
    @Anton-wc7lb Před rokem +1

    Amazing! This is great help!! :)

    • @marios_ideas
      @marios_ideas  Před rokem

      Subscribe to the channal if you like this content

  • @TheUnofficialMaker
    @TheUnofficialMaker Před 11 měsíci +1

    great explanation, I will try it

    • @marios_ideas
      @marios_ideas  Před 10 měsíci

      Cheers:) consider supporting my channel

  • @ernandofranco8448
    @ernandofranco8448 Před rokem +1

    Muito bem explicado!!!Parabéns pelo vídeo!

  • @arduinomaquinas
    @arduinomaquinas Před 10 měsíci

    Great video❤loved, awesome 🇧🇷😉👏👏👏👏👏👏

  • @PostalPete
    @PostalPete Před 3 měsíci

    This has been helpful but in my case I'm trying to use a mouse scroll wheel rotary encoder (which you can get from a computer mouse or buy from amazon). Setting it up in a similar fashion, I can get it to function roughly in the right direction - as I keep scrolling up or down, the counter reliably keeps increasing or decreasing as expected but sometimes it will go in the wrong direction as well. I tried experimenting with different resistors but haven't found a fix. Maybe there's something wrong with my wiring. I'm very new to this.

  • @jumbo999614
    @jumbo999614 Před rokem +1

    great video

  • @markgreco1962
    @markgreco1962 Před rokem

    Nice work

  • @plamenpetkov7132
    @plamenpetkov7132 Před 9 měsíci +1

    erratic behaviour is coming from contact bouncing. The simplest solution is to add caps to GND.

  • @sampetri4887
    @sampetri4887 Před 10 měsíci

    Thanks!

    • @marios_ideas
      @marios_ideas  Před 10 měsíci

      Thank you for your contribution:) Means a lot

  • @johancoetzee6540
    @johancoetzee6540 Před měsícem

    Thanks

  • @lgswitch4813
    @lgswitch4813 Před rokem

    good

    • @marios_ideas
      @marios_ideas  Před rokem

      My pleasure:) like the video and subscribe to my channal. Also consider supporting it.

  • @salim.studio
    @salim.studio Před 4 měsíci

    What happend if i connect the DT in the CLk, and The Clk in the DT ?

    • @marios_ideas
      @marios_ideas  Před 4 měsíci

      Then turning it clockwise would decrease the number and couterclocwise would increase it. So you would have opposite behaviour

  • @liverecon769
    @liverecon769 Před rokem

    Where is the code sir

  • @Scott.Farkus
    @Scott.Farkus Před 6 měsíci

    Once I move the knob on the encoder the output runs so fast I can't read it and keeps running even if I don't turn the knob anymore.
    Changed Serial.print to Serial.println and it starts a new line now, but the numbers don't change when I turn the encoder knob

    • @marios_ideas
      @marios_ideas  Před 6 měsíci

      Which exact place in the video you are reffering to

    • @Scott.Farkus
      @Scott.Farkus Před 6 měsíci

      @@marios_ideas I'm referring to the code I got from the link

  • @driss25
    @driss25 Před rokem

    Cd4026 et ne555 one kilo ehz

  • @egyrmexiq1
    @egyrmexiq1 Před 7 měsíci

    Excellent video, very didactic.. thanks..