Programming an Arduino Robot with Python 🐍

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

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

  • @YouMakeTech
    @YouMakeTech  2 ปีที่แล้ว +4

    Please hit the like button if you find this video helpful as a token of appreciation for all the effort it took to make this video and also so that this video can spread to more people. Thanks for your support!

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

    In today’s episode, *we will be programming a robot with Python* !
    0:00 Introduction
    1:43 FirmataStandard upload to the Arduino
    2:21 Servo-motors connection to the Arduino
    2:55 Move a servo with Python and pyFirmata
    3:56 Connect the 5 servos to the Arduino
    4:19 Programming the robot using Python
    5:30 Object-Oriented programming and the RobotArm class
    7:51 Conclusion

  • @haneen3731
    @haneen3731 3 ปีที่แล้ว +17

    This project was a great way to start learning programming robotic arms. Eventually, I was able to develop my own code and add Bluetooth to control the arm wirelessly. Thanks for sharing this project and I hope your channel grows even more!

    • @YouMakeTech
      @YouMakeTech  3 ปีที่แล้ว +5

      Thank you so much for your comment. This really encourages me to publish more content! I am glad if this video inspired you to tackle this project and to learn coding robots. This is awesome! The theme of my channel is "Design > Print > Build > Code > Play > Repeat". I plan to publish more content like this over time. Stay tuned!

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

      Post it up pleeease, would love to see this :)

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

    Subscribed, love this kind of stuff. Keep it up man

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

      Thanks for watching and for your comment!

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

    thanks this helped me get started!

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

      Cool ! Thanks for watching!

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

    Fantastic man.
    Great work!!

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

    Amazing video bro!

  • @haneen3731
    @haneen3731 3 ปีที่แล้ว +11

    This video is awesome! I would appreciate it if you could please make videos that explain the code in more detail. I find the hardware and connections to be easy, however I wish coding in the context of robotics can be explained more in depth. Thank you for sharing this wonderful project, I will definitely make it!

    • @YouMakeTech
      @YouMakeTech  3 ปีที่แล้ว +5

      Thanks for your comment. I like your idea. There are plenty of Python tutorials for beginners but learning by practicing is more fun. Robots are a cool way to learn programming. This robot was initially used to introduce my 12 years old son to coding with Python. Kids really like when they can see that code can move things outside of the computer. See you soon on YouMakeTech!

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

    Amazing project and video, thanks for sharing!

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

      Thanks for watching! If you enjoyed this video, take a look at YouMakeRobots: th-cam.com/video/ZrdnrW7ZXsA/w-d-xo.html . This is a 3D printed robot kit which allows you to design & build you own robots!

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

    Please how many degrees of freedom is the said robot arm?

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

    Amzing video bro keep up the great work

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

      Thanks for watching!

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

    what do you mean in the 10th minute,,? do I have to type it again or is it already in the coding, please explain

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

    Hi, I am trying to make this project and I noticed you mentioned the Arduino pins that you used. However, I would like to know which pins are specifically connected to which servo, like which pins is the servo on the base or the claw or the two hand servos connected to, as this will allow the connections to match the code you used I would appreciate the help. Thanks for sharing this project.

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

      Hi, looking back at the code, I used pins 3,5,6 9 and 10. Pin 10 is for the servo which opens/closes the gate, 9 for the servo of the hand. 3 is for the azimuth / base, 5 for the first arm and 6 for the 2nd arm.

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

      @@YouMakeTech Thank you so much!

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

    Thank you for helping with the hardware. I had one more question about the software. I uploaded your "servotest" file after installing pyfirmata and it worked. However, your "RobotArmDemo" file doesn't seem to work as it references the "RobotArm class" from the other file despite that the code says "from RobotArm import *". Sorry I am new to object oriented programming and classes and I tried googling how to use a class from another file into this one. If you could please link a video that shows how to do this or just explain how, I would really appreciate it. Thanks!

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

      You're welcome. Make sure you copy the 2 files RobotArm.py and RobotArmDemo.py in the same directory and that you cd to that directory before you start the Python interpreter. If it still does not import, try this : stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory

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

      @@YouMakeTech Thank you very much, I will try that!

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

    Where do I buy all equipments needed to build this robotic arm, I need it for ma son.

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

      Amazon is your best friend 😂 Take a look at this web page: www.youmaketech.com/arduino-robot-programming-with-python/

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

    How to use it with image processing? I need information about coding, I would appreciate it if you could help.I will use python and arduino programs.

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

    Awesome video, thanks for sharing. I have two questions if you don't mind: 1. It seems to work fine without any external battery, which really puzzles me. Since an Arduino UNO can only deliver 500mA I wonder if the one used in the video is an especial one that can provide much more power. Second question, about the method "MoveTo", the numbers represent just angles for each servo, or an (x, y, z) coordinate in space? Again, keep up the good work.

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

      Thanks for your comment. Regarding your questions: (1) It only works with a few micro servos because the Arduino Uno can only deliver 500mA. For more servos or bigger servos, you are right: an external power supply is required (2) In the current code, the coordinates are angles in degrees not x,y,z. In order to target x,y,z, a mathematical model must be added (Inverse Kinematic Model), which computes the joint angles from the desired x,y,z position in 3D space. Thanks for watching!

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

      Btw. I am watching your channel. Looks great! MicroPython is something I am really interested in too. If only you could provide english subtitles, your knowledge would reach a wider audience

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

      @@YouMakeTech Thanks for the suggestion, I am definitely considering that.

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

      @@andresmata8859 Cool, and you make games for Amstrad CPC too. CPC 6128 was my first computer. It is great! I found somebody in the world who shares the same passion as me!

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

    Sir how can we interface python with microcontrollers?I program microcontrollers by using C

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

      Sir, I don't understand exactly what you're trying to do. Do you want to program 100% in Python or do you want to interface a microcontroller with a computer program written in Python? Also take a look at this video: th-cam.com/video/TYPN3kH7gNU/w-d-xo.html . It is possible now to program microcontrollers directly in Python! Not only this is is easier to do, but you can do it interactively which shortens development time

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

      @@YouMakeTech I want to say that can we use python for PIC microcontrollers instead of C language?

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

      @@wahidali4378 I don't think so. PIC microcontrollers don't have enough power to run the Python interpreter directly like in the Raspberry Pi Pico. I was using Arduino but switched to Pi Pico because it is so convenient to be able to program 100% in Python

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

      @@YouMakeTech so in raspberry pi pico we can program the whole hardware? And also can do the image processing at the same time?

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

      Yes, you can access the whole hardware in Python 3 with the Raspberry Pi Pico. And interactively! You also get interrupts + timers + dual cores! I find this pretty amazing for a 4 $ chip! I haven't tried image processing on Pi Pico.

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

    Could you please share the coding you used?

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

      github.com/YouMakeTech/RobotArm

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

    sir i run the RobotArm module but the Robot doesn't move at all, plzz i need you're help

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

      Try to connect only one servo to the arduino pin 9 as shown in the video a nd see whether you can move it with the servoTest.py script: github.com/YouMakeTech/RobotArm/blob/main/servoTest.py

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

      @@YouMakeTech it worked with servoTest.py but still didn't work with RobotArm.py, when i type robot.goto() and write the numbers the code runs but not the robot, plz i need you're help this robot is my project for school

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

      @@abode5820 Try to run RobotArm with only one servo connected and see if it works. Maybe your 4 servos draw too much current and cannot be powered by the arduino. You may need to power the servos with a separate power supply

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

      @@abode5820 Which servos do you use? The arduino can only supply 100mA of current which only works for a couple of micro-servos. If you need more current, you have to power the servos with a separate 5 volts power supply or battery

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

      @@YouMakeTechi use 4 SG90 servos, when i run the up-down servo it goes down, but can't go up again

  • @10Minutes_Of_Code
    @10Minutes_Of_Code 2 ปีที่แล้ว

    Is it we can write the machine learning code

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

    Nice!, can you help me with something?
    I have connected my servo to pin 9 but when I'm trying to rotate the servo, it doesn't work... It just adds some degrees to the motor..
    Thank you

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

      Which servo do you use? Maybe try this first: www.arduino.cc/en/Tutorial/LibraryExamples/Sweep to see if this works

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

      @@YouMakeTech The servo itself works, do I need to turn the servo inside a While loop? Because I tested and it worked...

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

      no need for a while loop. myservo.write(0) should move the servo to 0 degree and my servo.write(180) should move the servo to 180 degrees.

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

    How can i use hc-12 with arduino using python language?

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

    Hi Installed Everything as it is!
    But servo doesn't work

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

      Please help

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

      Try www.arduino.cc/en/Tutorial/LibraryExamples/Sweep to see if this works

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

    Hi nice project. How to make the movement continuous?

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

      Hi, you need a trajectory generator like this: github.com/YouMakeTech/YouMakeRobots/blob/main/MotionProfile.cpp or github.com/YouMakeTech/micropython-robots/blob/main/TriangularMotionProfile.py . Instead of moving from one position to another in one step, you need to slew at constant speed. This is how smooth motion is achieved with commercial robots. Unfortunately, the hobby servos used have a small deadband and never move perfectly smoothly

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

      @@YouMakeTech Thank you very much.

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

    Votre video a ete tres enrichissante et comprehensible. Pour ceux qui ont decide d'ituliser raspberry pi au lieu d'arduino, dans quelle partie je devrai reediter?

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

      To control servos with the Raspi, the easiest way would be to use a PCA9685 board to connect the servos. Take a look at learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi

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

    Nice explanation, I like the accent :D

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

      The "french touch" 😂

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

    My new obsession ... Just started learning python and I want to program robots

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

    Awesome !!

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

    Very Informative :))))

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

    Fantastic! where to buy the arm?

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

      This one is 3d printed: www.thingiverse.com/thing:1015238 . You can buy a robotic arm from Sunfounder: www.sunfounder.com/collections/new-products/products/arduino-robot-arm-kit . Or better, you can buy a 3D printer! Not only you can use it for this project but for many others! And the Ender 3 is very affordable

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

    Can you do this but with arduinos language?

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

      Absolutely. With the exact same hardware, you can program the Arduino with its own language which is very close from C++. The issue is that it is very hard to program the motions because it is not interactive. Each time you want to change a motion, you have to recompile the code, upload it to the Arduino, fail, try again. Very time consuming... The benefit of using Firmata is that you can interactively send commands from the Python prompt. It is easier to get the motions right. And the Python language is easier to learn than C++ for beginners

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

    What is a pin in this project

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

      Take a look at www.arduino.cc/en/reference/board . The pins are shown on the Arduino board. Pins are where the wires are connected to the Arduino board. They are of various types depending on the type of signal: Analog, Digital, Digital PWM and do on

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

      Thanks

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

    Excellent

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

    Code not work

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

      It does, this is the exact same code I used for the video. What error message do you get?

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

      @@YouMakeTech Already extracted, still can't open

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

    hey i need some codes can you please write me?

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

    You are outstanding

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

    Total cost..?

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

      Check out this page: youmaketech.com/arduino-robot-programming-with-python/

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

    Great!

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

      Thanks for your comment 👍

  • @SaRa-vq7mk
    @SaRa-vq7mk 2 ปีที่แล้ว +1

    Super
    Merci

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

    Hey my Guy,
    I changed ur code a little bit and now i am finished i think mine is the better one for controlling the robot so i can send you the code so you can make a video about it or something like that and it shouldnt be a disrespect

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

      but it is still based on your code

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

    I am a 12 YR prodigy that dreams in robotics engineering this helps me get started for my engineering school.

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

      This robot is perfect to get started. It was used to initiate my 12 years old son to robotics and programming. I am currently working on a 3d printed robot kit. With this kit, you will be able to build any robot you like, from a simple robot to a complete humanoid robot. Stay tuned!

    • @user-oc1qw6uf3m
      @user-oc1qw6uf3m 3 ปีที่แล้ว +1

      Well, I'm 15 years old and I'm not a prodigy but I also want to learn ✔

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

      i have 18 years old... its to late to learn?

    • @user-oc1qw6uf3m
      @user-oc1qw6uf3m 3 ปีที่แล้ว +1

      @@quadcoptermediaandtech the most important thing is passion and motivation ! And be aware that it's never too late to learn !

  • @bryanst.martin7134
    @bryanst.martin7134 2 ปีที่แล้ว +3

    Can I offer some wisdom? Turn down or delete the music in the background. I actually can't call it background as it is as loud as the narrator. Why? I can only guess. I have worked, with, trained and entertained many thousands of people. The only time music was required was during DJ services at parties, etc. I want to learn this stuff but everyone has the same guide apparently. I also noticed the louder the music, the fewer subscribers. Couldn't make out what you said, and can't give a like. But I won't give a dislike either.

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

      You're absolutely right. The DJ music was a failed attempt to make the video a bit more "entertaining" ! I think I improved this in my recent videos. TH-cam is a learning journey for me!

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

    How can i use hc-12 with arduino using python language?.

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

      Do you really need hc-12? For short distances, HC-05 is much easier to use (no change in code). Your computer communicates with the Arduino over Bluetooth. See create.arduino.cc/projecthub/millerman4487/view-serial-monitor-over-bluetooth-fbb0e5

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

      @@YouMakeTech thank you but i wished if i can use hc12

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

      You probably can but unfortunately I cannot help because I haven't used this module yet.