Raspberry Pi Pico W LESSON 37: Control a Servo With a Potentiometer in MicroPython
HTML-код
- Опубликовано: 1 ноя 2024
- You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
In this class we will be using the Sunfounder Raspberry Pi Pico W Keppler Kit. It will make things a lot easier if we are working on identical hardware. the link below is to amazon, and is for the identical hardware I will be using in this entire class.
amzn.to/3ubMRs1
In this video, I will show you how to control a servo using the Raspberry Pi Pico W using a potentiometer. I show how the servo position is controlled by the pulsewidth of a pulse sent to the control lead of the servo. The potentiometer value is mapped to angle, and then the servo angle is converted to PWM value, which is sent to the servo. Enjoy!
[Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. ]
#raspberrypipicoW
#servo
#micropython
A wonderful servo lesson. This can be used to position a water valve in between opened and closed for cooling or heating something up in a PID loop. 🐬 Thank you so much.
Hi Paul, I'm your student from Kenya. Started 3 weeks ago with your incredible arduino lessons from 3 years ago. I am at lesson 39 and I have learnt so much. So today I decided to check out your latest video and I'm sad to see that you changed your iconic orange t-shirt and coffee mug.😢. You still a great teacher though. May you live longest and God bless you.
Thanks Paul! It is the Math component of the lesson what makes me come back every time. A little late but catching up.
Excellent!
Thanks Paul. I did the homework successfully but our math was different. You Rock
PAUL ALWAYS HAS GREAT LESSONS TO LEARN BY!
Excellent video. Math works!
I AM LEGEND! Rather than converting potVal to degrees and using Paul's degrees-to- duty cycle formula, I did the math and converted directly from potVal to duty cycle. Ain't math fun?
Another Great Video Paul. Thanks for your hard work to make them.
Thank you Paul!
Thanks Paul.
Thanks sir ❤
this comment is solely for youtube juice. Good video, thanx!
I managed the homework. The math still escapes me with the substitution of variables but I'm getting there.
Has any done anything with the addressable christmas lights? What would be a good reference?
There is a built in Neopixel module in Micropython. Here is the example code from the docs
from machine import Pin
from neopixel import NeoPixel
pin = Pin(0, Pin.OUT) # set GPIO0 to output to drive NeoPixels
np = NeoPixel(pin, 8) # create NeoPixel driver on GPIO0 for 8 pixels
np[0] = (255, 255, 255) # set the first pixel to white
np.write() # write data to all pixels
r, g, b = np[0] # get first pixel colour
Basically the pixels are in an array and you set the R,G,B values (0 - 255). The .write method sends the data array out to the pixels. It is great fun making patterns using loops. There is also a similar dotstar (APA102) module for the more expensive other style of addressable LEDs.
I am legend.
LEGEND!
I made the homework succesful
You are a good electronics guy,
Please help.I have copied ths code exactly using thonny with the micropython-servo library installed.
However,what seems to be happening is that my servo turns on its own without my input when i run the program.
I have switched out the potentiometer for a better one but still get the same outcome.
Any ideas where im going wrong?
All sorted,ihad my wiring wrong
I keep getting Thonny backend errors when running anything with the servo. Sometimes it will work for a few seconds and crash. Not sure why. I am on a Mac M2 and the code is exactly as shown in the video
I'm getting the exact same thing. I have a Mac as well and it is happening with any program I try with the servo and Potentiometer. I have used several styles of pots and the same happens. (also tried averaging the pot values in an effort to make them more consistent and that did not help.
on VSCode I get:
Exception occured (maybe a connection loss) and on Thonny I receive:
Process ended with exit code 1.
Unable to connect to /dev/cu.usbmodem101: [Errno 2] could not open port /dev/cu.usbmodem101: [Errno 2] No such file or directory: '/dev/cu.usbmodem101'
Process ended with exit code 1.
Unable to connect to /dev/cu.usbmodem101: [Errno 35] Could not exclusively lock port /dev/cu.usbmodem101: [Errno 35] Resource temporarily unavailable
If you have serial connection to the device from another program, then disconnect it there first.
Hello Paul, I just stumbled on your channel. Have a quick question for you. Is there any way that you can use an arduino to measure distance accurately? Like a machine DRO
Yes, there are several ways to use an Arduino to measure distance accurately. One common approach is to use an ultrasonic sensor such as the HC-SR04 to measure the distance between the sensor and an object. The sensor emits high-frequency sound waves and measures the time it takes for the sound waves to bounce back. Based on this time measurement, the Arduino can calculate the distance to the object.
Another approach is to use a laser distance sensor such as the VL53L0X or the Sharp GP2Y0D810Z0F. These sensors use laser light to measure distance and can provide very accurate readings.
There are also other sensors that can be used to measure distance, such as infrared sensors, but their accuracy may be limited and they may be affected by ambient light conditions.
Regardless of the sensor used, the Arduino can be programmed to process the distance measurements and display them on a LCD screen or send them to a computer for further analysis.
He made a video
I am legend, but broke my oled screen during the process of making, and was so annoyed to record the solution because of that...