Using a Rotary Encoder with a Raspberry Pi Pico

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 พ.ย. 2024

ความคิดเห็น • 51

  • @poijmc606
    @poijmc606 2 ปีที่แล้ว +1

    Very well made video! Theoretical introduction, connections, code and everything perfect! :)

  • @Toschez
    @Toschez 3 ปีที่แล้ว +6

    I had a problem with Pico + rotary encoder + CircuitPython (with rotary encoder library); the input weren’t recognised. After hours of troubleshooting I realised the directional pins should not share the same PWM channels. Seems like an easy beginner pitfall but not discussed much?

  • @mikenesbitt8052
    @mikenesbitt8052 3 ปีที่แล้ว +4

    OK new here, where can I get board and digitalio? tried doing this project and could compile.

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      Which firmware are you running on your pico?

    • @mikenesbitt8052
      @mikenesbitt8052 3 ปีที่แล้ว

      @@PrintNPlay v1.17 (2021-09-02)

  • @qzorn4440
    @qzorn4440 ปีที่แล้ว

    Sweet little example. 😎 Thanks.

  • @zipp4everyone263
    @zipp4everyone263 2 ปีที่แล้ว

    Great and simple video! If you know, I'd love to see this in some more detail but regarding to the rp2040 chip in a naked design. I'm currently trying to learn hardware engineering a d as such I'm building my own keyboard. It will feature 3 rotary encoders and an i2c display. The i2c pins and logic I'm fairly certain of but it would be lovely to have resistors and good to knows added into an example :)

  • @lsmith2030
    @lsmith2030 3 ปีที่แล้ว +1

    I’m looking at learning how to create flight sim panels with switches, potentiometers and rotary encoders but at the moment know zero about coding, I am reasonable with electrics and very computer minded the only problem is know nothing about coding, could you recommend a good place to start or learn?

    • @lsmith2030
      @lsmith2030 3 ปีที่แล้ว

      And can you recommend whether it would be better to learn the pico or an arduino?

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      I can poke around a bit, but I think there are a few open source projects you could follow to so just that! In terms of Pico vs Arduino, ai think Arduino is likely still the best choice, mostly for the amount of support and sample code that already exists.
      Let me know if you need help finding samples of similar projects, I'm glad to help

  • @SoggyCashew
    @SoggyCashew 2 ปีที่แล้ว +1

    I want to read values like a potentiometer to determine tilt. For example tilt down, level and tilt up. How can i do this with micropython on the pico? Thanks!!!

    • @PrintNPlay
      @PrintNPlay  2 ปีที่แล้ว

      As luck would have it, I coded a version of space invaders that uses a potentiometer to control the ship. I can give more details later if you want but for now, here's the video on it th-cam.com/video/O5S1LC5TFiM/w-d-xo.html

    • @SoggyCashew
      @SoggyCashew 2 ปีที่แล้ว

      @@PrintNPlay im very new to this and looking at the github code there is to much going on for me....

  • @axelittle8463
    @axelittle8463 2 ปีที่แล้ว

    2:47 ✨Yesss stepPin✨

  • @PaulaBean
    @PaulaBean 2 ปีที่แล้ว +1

    What happens if you keep turning to one direction? Will it output multiple times 'right, to the right'?

    • @PrintNPlay
      @PrintNPlay  2 ปีที่แล้ว

      Yup, it just pulses each time, so you can go infinitely in either direction.

  • @bigfopa786
    @bigfopa786 ปีที่แล้ว

    hey! is there a MicroPython version of the code? I can't figure it out myself :(

    • @blikpils
      @blikpils ปีที่แล้ว

      from machine import Pin
      import utime
      dirPin = Pin(16, Pin.IN, Pin.PULL_UP)
      stepPin = Pin(17, Pin.IN, Pin.PULL_UP)
      previousValue = True
      while True:
      if previousValue != stepPin.value():
      if stepPin.value() == False:
      if dirPin.value() == False:
      print("Left")
      else:
      print("right")
      previousValue = stepPin.value()

  • @edwardarruda7215
    @edwardarruda7215 3 ปีที่แล้ว +2

    Clockwise etc

  • @gshelton
    @gshelton 3 ปีที่แล้ว +2

    Nice job. I learned something! I never knew how a rotary encoder worked. Thanks!!

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      See you in the garage!

    • @lancekarsyn535
      @lancekarsyn535 3 ปีที่แล้ว

      i realize I'm pretty randomly asking but do anybody know of a good place to stream new tv shows online?

    • @zanderdillon7730
      @zanderdillon7730 3 ปีที่แล้ว

      @Lance Karsyn flixportal :)

    • @lancekarsyn535
      @lancekarsyn535 3 ปีที่แล้ว

      @Zander Dillon thanks, I signed up and it seems to work :) I appreciate it !!

    • @zanderdillon7730
      @zanderdillon7730 3 ปีที่แล้ว

      @Lance Karsyn glad I could help xD

  • @johnberzins3091
    @johnberzins3091 3 หลายเดือนก่อน

    please put your code in the description

  • @Hristifor1
    @Hristifor1 3 ปีที่แล้ว

    Is a 5v encoder good for this task or should I find a 3.3v one?

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      In most cases, the encoder is acting like two buttons being pressed. So 3.3v in and out should be fine. Just don't connect 5v to it and connect the output to the pico, it can damage the Pico immediately or over time

  • @cerilious
    @cerilious 2 ปีที่แล้ว

    Is there a reason we use pullup instead of pulldown?

    • @cerilious
      @cerilious 2 ปีที่แล้ว

      Would we have to connect to voltage instead of ground if we pulled low?

    • @PrintNPlay
      @PrintNPlay  2 ปีที่แล้ว

      If you pull low, you will want to use the 3.3v pin. The Pico is not 5v tolerant on its input/output pins.

  • @TheTurmanDreams
    @TheTurmanDreams 3 ปีที่แล้ว +1

    Great!!!

  • @tonydean7543
    @tonydean7543 ปีที่แล้ว

    I notice that you do not connect the + pin of the encoder to + supply. If you don't do this, the pull-up resistors on the encoder can prevent an input pin exceeding the '1' threshold if the other pin is driven low (to ground) by the encoder, which may lead to unreliable operation, even if the microcontroller internal pull-ups are enabled. It is advisable to connect the + pin to the 3v3 pin (pico pin 36). Please do not connect the + pin of the encoder to +5V (as is marked on some encoders) as the pico inputs are 3.3V and inputting 5 volts is not a good idea, even though the 10Kpull-ups will give some protection.

  • @lIlIlIIlIlIlIlIlIlI
    @lIlIlIIlIlIlIlIlIlI 3 ปีที่แล้ว

    Cool!

  • @autobus11a
    @autobus11a 3 ปีที่แล้ว +1

    The rotaryio library is not neccessary?

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      Not for basic usage, but the library does allow for easier tracking of position if that is your goal with the use of your rotary encoder, as well as support for other types of encoders.

    • @autobus11a
      @autobus11a 3 ปีที่แล้ว

      @@PrintNPlay you changed the wiring, why?

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      I'm not sure what you mean?

    • @autobus11a
      @autobus11a 3 ปีที่แล้ว

      @@PrintNPlay First yellow is on GP17, then on GND.

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      @@autobus11a oh, my bad! The video was filmed out of order. The wiring order in the tutorial and in the diagram is correct.

  • @TomLeg
    @TomLeg 3 ปีที่แล้ว +1

    Silly question, why over-complicate things with "while 1 == 1"? Why not "while True" .. which is what your version boils down to. False values are an empty string, the number zero, or an empty list, tuple, set, or dictionary. Everything else is TRUE. So the simplest version would be "while 1".

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว +4

      Not a silly question at all. I've been working in a language where there aren't True and False constants built in...
      So, short answer, my context switching needs some work.

    • @TomLeg
      @TomLeg 3 ปีที่แล้ว

      @@PrintNPlay The idiomatic aspects of a language are the hard parts to learn. writing X that looks like Xand not like Y :-)

  • @FruchtcocktailUndCo
    @FruchtcocktailUndCo 3 ปีที่แล้ว +1

    please use interrupts

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว

      Absolutely. One of the next tutorials will be interrupt use.

  • @handdancin
    @handdancin ปีที่แล้ว

    just say while 1. while 1 == 1 is pointless

  • @odissey2
    @odissey2 3 ปีที่แล้ว

    Unfortunately, those encoders (looks like KY-40) produce terrible ringing, which makes it useless without some sort of debouncing. It is terrible code that consumes all processor clock on such slow and rare action as the manual encoder.

    • @PrintNPlay
      @PrintNPlay  3 ปีที่แล้ว +2

      The code merely demonstrates the expected input from the encoder. As it's only purpose is to monitor for changes the encoder, the usage of the processor clock is irrelevant. I'm sorry you didn't find the walk-thru useful.