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

Комментарии • 28

  • @qzorn4440
    @qzorn4440 Год назад +1

    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.

  • @navinlessing7053
    @navinlessing7053 Год назад

    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.

  • @edSabio572
    @edSabio572 Год назад

    Thanks Paul! It is the Math component of the lesson what makes me come back every time. A little late but catching up.

  • @stephenlightkep1621
    @stephenlightkep1621 Год назад

    Thanks Paul. I did the homework successfully but our math was different. You Rock

  • @larryplatzek9017
    @larryplatzek9017 Год назад +1

    PAUL ALWAYS HAS GREAT LESSONS TO LEARN BY!

  • @huen5047
    @huen5047 Год назад

    Excellent video. Math works!

  • @cbrombaugh
    @cbrombaugh Год назад

    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?

  • @TheTechRancher
    @TheTechRancher Год назад

    Another Great Video Paul. Thanks for your hard work to make them.

  • @scottwait3585
    @scottwait3585 Год назад

    Thank you Paul!

  • @patrickfox-roberts7528
    @patrickfox-roberts7528 Год назад

    Thanks Paul.

  • @Ahmed_I.Q
    @Ahmed_I.Q Год назад

    Thanks sir ❤

  • @VeryUsMumblings
    @VeryUsMumblings 8 месяцев назад

    this comment is solely for youtube juice. Good video, thanx!

  • @rschook7762
    @rschook7762 Год назад

    I managed the homework. The math still escapes me with the substitution of variables but I'm getting there.

  • @robakers6127
    @robakers6127 Год назад

    Has any done anything with the addressable christmas lights? What would be a good reference?

    • @keithlohmeyer
      @keithlohmeyer Год назад +1

      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.

  • @brucemilyko8549
    @brucemilyko8549 11 месяцев назад

    I am legend.

  • @AmitGupta-un3st
    @AmitGupta-un3st Год назад

    I made the homework succesful

  • @retrobombstudios1258
    @retrobombstudios1258 11 месяцев назад

    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?

  • @CayMacVintage
    @CayMacVintage 11 месяцев назад

    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

    • @jbelmont72
      @jbelmont72 10 месяцев назад

      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.

  • @brandonculver2403
    @brandonculver2403 Год назад

    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

    • @jeremiebula4370
      @jeremiebula4370 Год назад

      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.

    • @AmitGupta-un3st
      @AmitGupta-un3st Год назад

      He made a video

  • @freddyveza
    @freddyveza 7 месяцев назад

    I am legend, but broke my oled screen during the process of making, and was so annoyed to record the solution because of that...