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?
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 :)
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?
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
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!!!
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
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
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.
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.
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".
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.
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.
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.
Very well made video! Theoretical introduction, connections, code and everything perfect! :)
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?
Very good point - thanks!
OK new here, where can I get board and digitalio? tried doing this project and could compile.
Which firmware are you running on your pico?
@@PrintNPlay v1.17 (2021-09-02)
Sweet little example. 😎 Thanks.
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 :)
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?
And can you recommend whether it would be better to learn the pico or an arduino?
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
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!!!
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
@@PrintNPlay im very new to this and looking at the github code there is to much going on for me....
2:47 ✨Yesss stepPin✨
What happens if you keep turning to one direction? Will it output multiple times 'right, to the right'?
Yup, it just pulses each time, so you can go infinitely in either direction.
hey! is there a MicroPython version of the code? I can't figure it out myself :(
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()
Clockwise etc
Nice job. I learned something! I never knew how a rotary encoder worked. Thanks!!
See you in the garage!
i realize I'm pretty randomly asking but do anybody know of a good place to stream new tv shows online?
@Lance Karsyn flixportal :)
@Zander Dillon thanks, I signed up and it seems to work :) I appreciate it !!
@Lance Karsyn glad I could help xD
please put your code in the description
Is a 5v encoder good for this task or should I find a 3.3v one?
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
Is there a reason we use pullup instead of pulldown?
Would we have to connect to voltage instead of ground if we pulled low?
If you pull low, you will want to use the 3.3v pin. The Pico is not 5v tolerant on its input/output pins.
Great!!!
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.
Cool!
The rotaryio library is not neccessary?
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.
@@PrintNPlay you changed the wiring, why?
I'm not sure what you mean?
@@PrintNPlay First yellow is on GP17, then on GND.
@@autobus11a oh, my bad! The video was filmed out of order. The wiring order in the tutorial and in the diagram is correct.
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".
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.
@@PrintNPlay The idiomatic aspects of a language are the hard parts to learn. writing X that looks like Xand not like Y :-)
please use interrupts
Absolutely. One of the next tutorials will be interrupt use.
just say while 1. while 1 == 1 is pointless
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.
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.