Multiple Servo Motor Control with Joystick and Arduino

Поделиться
HTML-код
  • Опубликовано: 14 дек 2016
  • In this tutorial, we will learn how to use multi-servo with Joystick. We will control two pcs servo motor with one Joystick. You can implement your robotic arm projects with reference to this tutorial. Of course we will use external battery / power when doing this.
    Also see this project: mXY Board - Low-Budget XY Plotter Drawing Robot Board • Make XY plotter drawin...
    Required Hardwares:
    1x Arduino UNO R3:
    bit.ly/2xt9MVk
    amzn.to/2LZr6t4
    2x Servo Motor:
    bit.ly/2JfGtuj
    amzn.to/3avwe1N
    1x Joystick Module:
    bit.ly/2kJkU7a
    amzn.to/3u5097N
    3 in 1 Jumper Wire:
    bit.ly/2J6de9E
    amzn.to/3doetmT
    1x Breadboard:
    bit.ly/2H9YSUa
    amzn.to/3qxLxwm
    Recommended Items:
    Use Your Muscles in Project - amzn.to/3wdL45C
    37 Sensor & Module Packages - amzn.to/3m66WeQ
    Try this Robot Arm - amzn.to/3fq8DCl
    Best Resin 3D Printer - amzn.to/39tY8KB
    Arduino Compatible Kits - bit.ly/2J2AFF7
    Banggood Spring Sale - bit.ly/3slMbOn
    Source Code:
    github.com/MertArduino/Multip...
    Connections:
    The external battery VCC / GND connect to the breadboard.
    The Arduino GND connect to the breadboard's GND input
    The Servo1 VCC and GND connect to the breadboard's VCC / GND inputs
    The Servo1 Signal connect to the Arduino Digital PWM 3
    The Servo2 VCC and GND connect to the breadboard's VCC / GND inputs
    The Servo2 Signal connect to the Arduino Digital PWM 5
    The Joystick GND connect to the Arduino GND
    The Joystick VCC connect to the Arduino VCC
    The Joystick 'X' (in some modules 'H') connect to the Arduino Analog 0
    The Joystick 'Y' (in some modules 'V') connect to the Arduino Analog 1
    The Joystick 'SW' (switch or button) not connected.
  • НаукаНаука

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

  • @maker101io
    @maker101io  3 года назад +8

    Source Code: github.com/MertArduino/Multiple-Servo-Motor-Control-with-Joystick-and-Arduino
    Recommended Items:
    Use Your Muscles in Project - amzn.to/3wdL45C​
    37 Sensor & Module Packages - amzn.to/3m66WeQ​
    Try this Robot Arm - amzn.to/3fq8DCl​
    Best Resin 3D Printer - amzn.to/39tY8KB​
    Arduino Compatible Kits - bit.ly/2J2AFF7​
    Banggood Spring Sale - bit.ly/3slMbOn

  • @GhostRiderSpiritOfVengeance
    @GhostRiderSpiritOfVengeance 3 года назад +14

    I spent my entire weekend looking for a tutorial that describes how to set this up in full detail from a beginner standpoint. Thank you.

  • @samuelhawksworth1923
    @samuelhawksworth1923 6 лет назад +4

    I’m subbing to you dude, I’ve been needing this help with my project for a year and your the first person to help me in an easy way

  • @dngineer
    @dngineer 5 месяцев назад

    Perfect. Came in clutch for my Engineering NEA exam. Thank you so much

  • @vidmantasjuska4084
    @vidmantasjuska4084 7 лет назад +164

    Here is code people
    //add the servo libary
    #include
    //define our servos
    Servo servo1;
    Servo servo2;
    //define joystick pins (Analog)
    int joyX = 0;
    int joyY = 1;
    //variable to read the values from the analog pins
    int joyVal;
    void setup ()
    {
    //attaches our servos on pins PWM 3-5
    servo1.attach(3);
    servo2.attach(5);
    }
    void loop ()
    {
    //read the value of joystick (betwen 0-1023)
    joyVal = analogRead(joyX);
    joyVal = map(joyVal, 0, 1023, 0, 180); //servo value betven 0-180
    servo1.write(joyVal); //set the servo position acording to the joystick value
    joyVal = analogRead(joyY);
    joyVal = map (joyVal, 0, 1023, 0, 180);
    servo2.write(joyVal);
    delay(15);
    }

  • @stefan7745
    @stefan7745 7 лет назад

    Your video helped out a lot in the turret project I was doing, thank you very much!

  • @benfree_man
    @benfree_man 4 года назад +9

    I appreciate this so much. Helped me a ton!

  • @toa7914
    @toa7914 2 года назад +1

    Awesome video, dude. First time using servos and i feel very accomplished. +1 like

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

    cleanest video made for any Arduino project. Thank you for sharing!

  • @aniketpratap8387
    @aniketpratap8387 2 года назад +1

    Excellent and Such a simple explanation ….. People like you make this world a better place....

  • @Soniboy84
    @Soniboy84 6 лет назад +1

    This was very helpful, thank you for the video!

  • @indivsultanabinavsi8909
    @indivsultanabinavsi8909 7 лет назад +13

    Not All Heroes wearing capes. Thank you for the tutorial

  • @thedirty530
    @thedirty530 6 лет назад +1

    Awesome Videos! Content and editing are great!

  • @Maggot-ov4eu
    @Maggot-ov4eu 5 лет назад

    This is so under appreciated. Thy is had to be the best tutorial

  • @JefferyLovegrove
    @JefferyLovegrove 6 лет назад

    Great video! Thanks for the info and demonstration.

  • @aldrinlimos5159
    @aldrinlimos5159 4 года назад

    Just bought an Arduino recently, and I hadn't read any of the documentation yet. Took me an hour to try and fiddle with the wonky 0-512,512-1024 range with some crude equations to have the servo move with the switch. Kept freezing and moving occasionally before I decided to look for a video like this :P.

  • @xiaosan12162009
    @xiaosan12162009 6 лет назад

    谢谢,好视频,通俗易懂,看了就想自己尝试一下

  • @Ratpack30
    @Ratpack30 5 лет назад

    a big thank you, this helped me with my little project.....

  • @mattdriller1
    @mattdriller1 6 лет назад

    Excellent tutorial, Thanks!! It would have been extra cool if you had popped up a link to the sketch. Thanks again.

  • @kung-fupanda-vu5ns
    @kung-fupanda-vu5ns 7 лет назад

    thank you for the video.. at last I got the exact video which I wanted

  • @MrTaz6552
    @MrTaz6552 7 лет назад

    Great to see some new, good, arduino videos. Thanks

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

    Thank you, it was very useful for me. Greetings from Hungary.

  • @hetshah7490
    @hetshah7490 4 года назад

    Simple and sweet
    Thank you
    I will try it in avr codings

  • @realtrickybilly
    @realtrickybilly 6 лет назад

    Thank you. I have made your project, used different materials for the arms though. Awesome robot arm.

  • @lordnever1
    @lordnever1 6 лет назад +3

    This is my very first Arduino project and it worked great! I am so happy that I watched this video. Time for my next project, thanks a lot great video!

    • @kamenstefanov2811
      @kamenstefanov2811 5 лет назад

      Didn't you have error in the code?

    • @kkrokingkiller456
      @kkrokingkiller456 4 года назад

      @@kamenstefanov2811 for me it does't work

    • @kamenstefanov2811
      @kamenstefanov2811 4 года назад +1

      @@kkrokingkiller456 it was a long time ago but i remeber that the mistake was very simple if you look closely you'd find it

    • @kkrokingkiller456
      @kkrokingkiller456 4 года назад

      @@kamenstefanov2811 thanks

  • @oOcitizenOo
    @oOcitizenOo 7 лет назад

    Accidentaly ran into your channel. Subbed!
    And like for the country music :)

  • @sebastianalejandro1273
    @sebastianalejandro1273 6 лет назад

    Thank you, great tutorial!!!

  • @zzzzzz...9902
    @zzzzzz...9902 7 лет назад +93

    It works! It works! The dislike button works! Joke, the circuit works and the like button works. Runs like my girlfriend.

    • @zzzzzz...9902
      @zzzzzz...9902 7 лет назад +4

      Your welcome. Sorry to hear about your computer, I fix them for a living, xd.

    • @tommybirchify
      @tommybirchify 5 лет назад +2

      @@zzzzzz...9902 good one XD

    • @hieroja9774
      @hieroja9774 4 года назад +1

      wtf bro

    • @mateom7201
      @mateom7201 3 года назад +2

      So dirty?

    • @realSethMeyers
      @realSethMeyers 3 года назад +1

      I have tuberculosis

  • @MultiCreasey
    @MultiCreasey 7 лет назад +34

    Thank you, a really clear and helpful video. Appreciate your time in making it and for sharing.

  • @ojastheai
    @ojastheai 4 года назад

    A perfect tutorial....
    Thank you it helped me a lot...😊😊

  • @rebeccatorbergsen
    @rebeccatorbergsen 3 года назад

    this is why i follow you, quality videos

  • @hkiceman001
    @hkiceman001 7 лет назад

    Thank you, a very helpful video for me. I watch all your video to learn arduino...thx too much

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

    Parabéns pelo vídeo e por compartilhar o seu conhecimento! 🙂

  • @wahidaaziz9588
    @wahidaaziz9588 7 лет назад

    Thank you for the video. It really help me. How about use 3 servo motor?

  • @corywilliamsmith
    @corywilliamsmith 7 лет назад

    This is amazing. Thank you. This will be my next project for sure. can you teach me how to replace one of those servos with a DC motor? :]

  • @zcxvasdfqwer1234
    @zcxvasdfqwer1234 6 лет назад

    Very nice short clear video.

  • @rajeevabariar7737
    @rajeevabariar7737 7 лет назад +1

    great dude
    hey I wanted to make a simple nano quad using small DC motors(the one used in RC helicopters)
    but how can I vary the speed of four motors simultaneously
    please reply

  • @Jacobtaylor1775
    @Jacobtaylor1775 7 лет назад

    Thank you very much! The wiring and code worked flawlessly! (copied code from video)

  • @loganmitchell2388
    @loganmitchell2388 3 года назад

    best tutorial ive seen so far! how would I make the servo stop at its givin location when I let off of the joystick?

    • @b3dubbs72
      @b3dubbs72 2 года назад

      probably set the position of the servo if the joystick returns to neutral as the last read value. I'm not sure how to you'd go about doing that but I'm sure there's a 'last' function

  • @syahrul9282
    @syahrul9282 7 лет назад

    hope you will keep making more cool projects u earn my sub

  • @emadabuhagag222
    @emadabuhagag222 3 года назад

    great tutorial , thank you

  • @syahrul9282
    @syahrul9282 7 лет назад +1

    man ty so much really what im looking for thank god bless u man!!! because i am searching this to make the robot arm actually😂

  • @ZenHulk
    @ZenHulk 7 лет назад

    i'm a beginner....can i hook it up just as you directed, but have two servos work on the Y and one on the X axis. Thank You i find lots of useful stuff on your tutorials.

  • @Acorama
    @Acorama 7 лет назад

    Eline sağlık , çok faydalı bir çalışma

  • @musabmahmood1196
    @musabmahmood1196 7 лет назад +2

    sir if i want to connect servos on one aurdino and connect to NRF24L01 module and joystick on other aurdino with another NRF24L01 wireless module................then something change in code will occur or not?? can i put servos code to one ardino and analog joystick code on other ardiuno then it would be correct or not ?? if not then plz help me

  • @durvesularevanth1797
    @durvesularevanth1797 6 лет назад

    can u pls instruct me how to controll aesc with rc tx interfacing with arduino .....reading the signal and then delivering them to the esc.

  • @MrHristoB
    @MrHristoB 6 лет назад

    Thank you!! Subscribed...

  • @Electromaniaworld
    @Electromaniaworld 6 лет назад

    thanks. i was looking for this to control servo for toy truck. i want to add servo to my police car shown in my recent video. any suggestions. i want to have moving wiper

  • @MrHenryrolls
    @MrHenryrolls 7 лет назад +7

    Lovely clear tutorials Mert. Thank you. Just one concern, the servo in my kit looks identical (SG90), yet checking its operating voltage online it's 3.0-7.2v (ideally 4.8v). I don't want to blow it on my first attempt.

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

      It’s blew my board! Don’t try it.

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

      ​@Frectieyou don't need to add a battery if that is the servo spec, just plug it straight into the board

  • @reeceburns5681
    @reeceburns5681 4 года назад

    is there anyway to get the servos to hold their position until you want it to go more or another way?

  • @christiankalebe1022
    @christiankalebe1022 7 лет назад

    SHOWWWWWWW.. PERFECT. CONGRATULATIONS

  • @embhahlangpakyntein4223
    @embhahlangpakyntein4223 6 лет назад

    so i'd like to know how would i change the code if i dont want the motor to return to its initial position if i let go of the stick

  • @danieldemaria
    @danieldemaria 3 года назад

    Se pueden conectar 6 servos en paralelos 3 que se muevan en X y 3 que se muevan en Y? con este mismo procedimiento?

  • @J.H.DESIGNS
    @J.H.DESIGNS 11 месяцев назад

    Thanks for this video 😄

  • @CoyoteFPV
    @CoyoteFPV 7 лет назад

    Could you share the code to enable the joypads momentary switch to scroll through a 3rd servo channel. it 1000us 1500us and then on the third press 2000us

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

    this is what i was looking for lol
    finnaly i found it

  • @romeo1245
    @romeo1245 5 лет назад

    how about 1 small servo and big servo do i need to add other components thanks?

  • @turtlebrownies8701
    @turtlebrownies8701 6 лет назад

    is it ok if instead of using a custom battery unit, I use a power supply module?

  • @saqibcom
    @saqibcom 6 лет назад +7

    //add the servo library
    #include
    //define our servos
    Servo servo1;
    Servo servo2;
    //define joystick pins (Analog)
    int joyX = 0;
    int joyY = 1;
    //variable to read the values from the analog pins
    int joyVal;
    void setup()
    {
    //attaches our servos on pin PWM 3-5
    servo1.attach(3);
    servo2.attach(5);
    }
    void loop()
    {
    //read the value of joystick (between 0-1023)
    joyVal = analogRead(joyX);
    joyVal = map (joyVal, 0, 1023, 0, 180); //servo value between 0-180
    servo1.write(joyVal); //set the servo position according to the joystick value
    joyVal = analogRead(joyY);
    joyVal = map (joyVal, 0, 1023, 0, 180);
    servo2.write(joyVal);
    delay(15);
    }

  • @fazmisharaff8839
    @fazmisharaff8839 6 лет назад +8

    Plz make a wireless version using a bluetooth module but great video you just got a new sub!

  • @andreabinotto9930
    @andreabinotto9930 6 лет назад +9

    Thank you, great tutorial ;), what's the name of this song?

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

    Is there any way to control the servos as a unit. I need both servos to go forward when i push the joystick forward but one to back off as i pull the stick sideways. All I’ve been able to find is the configuration shown in this video

  • @ericpapainmezatio861
    @ericpapainmezatio861 6 лет назад

    THANK YOU FOR VIDEO

  • @lightpainter7
    @lightpainter7 7 лет назад

    Nice project. Thank You. Will you please tell me about the music for this video?

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

    wow soy de Colombia y me gustó el canal video, tiene un curso completo de Arduino?, Thanks

  • @frobinson2413
    @frobinson2413 6 лет назад

    I know I am a late starter. But I would like to use the same setup but control 2 stepper motors instead. I am a complete noob, but could I use the same code?

  • @muratyuksektepe
    @muratyuksektepe 6 лет назад

    Güzel video olmuş. Başarılar dilerim hocam.

  • @chenariana3482
    @chenariana3482 4 года назад

    Where can I get the external battery VCC/GND... I mean that part which connects to the wires

  • @user-fc8gq3gl4z
    @user-fc8gq3gl4z Год назад

    this looks fun

  • @daxliniere
    @daxliniere 3 года назад +15

    The problem is that when you release the joystick, the motor returns to the centre position. The code also needs some averaging to account for the jittery values from the A/D converter.

    • @user-yr7wl9mt6h
      @user-yr7wl9mt6h 9 месяцев назад

      Have you found a solution to this?

  • @JesseGunnRocksnyc
    @JesseGunnRocksnyc 6 лет назад

    Nice! I think this is what I was looking for! But is there a way to add ease in and ease out? In other words smoothing when starting and stopping. So it is not abrupt.

    • @JesseGunnRocksnyc
      @JesseGunnRocksnyc 6 лет назад

      Also I noticed that I have 6 wires 3 black red and white on top and 3 on the side. Do they share the red wire?

  • @dearcustomers2023
    @dearcustomers2023 7 лет назад

    Very helpful..Thank yu

  • @oikmo
    @oikmo 3 года назад

    hey just asking if i wanted a second joystick that controlled to more servos how would i do it?

  • @LTDBlogOffical
    @LTDBlogOffical 7 лет назад

    I like schanel!Good!

  • @sonatachmieliauskiene258
    @sonatachmieliauskiene258 4 года назад

    it so nice! it works.

  • @kaidnl
    @kaidnl 7 лет назад

    Hello Mert,
    I want to do the same as this, only I want the stepper to make little steps as I move the joystick. and when I centre the joystick It should stay at the last location until I move the joystick again, hope you understand what I mean. Can you show us how you would change the code for that?

  • @tushartambe2061
    @tushartambe2061 6 лет назад

    This is really good!!Can we create Simulink file for the same?

  • @jus4uvacationrental462
    @jus4uvacationrental462 6 лет назад

    Hello i have got a 3dr iris+ and i have just bought a pan/tilt mount with sg90 servo is it possible that you would know how to connect it to i believe it is call a pixhawk v2.4.5
    Thank you
    don

  • @varcelymif6334
    @varcelymif6334 5 лет назад

    Hi,how can I do to use switch (bouton ) of joystick?

  • @grahamtech
    @grahamtech 7 лет назад

    hi im building a robotic hand , and i wanted to know if thers any way you could tell me how to control 5 servos with analog joysticks or one joystick to control all five

  • @victorsandoval6145
    @victorsandoval6145 6 лет назад +1

    Como le hizo para poner el compilador de color negro

  • @mangeshmahajan4445
    @mangeshmahajan4445 7 лет назад +1

    thank you! what music is playing?

  • @AhmadFanoon
    @AhmadFanoon 7 лет назад

    Please I want to explain the work of reagent water.

  • @83eroastery96
    @83eroastery96 6 лет назад

    Deciding on Arduino or Phidgets then I found your site. My project is controlling a valve with a 10k pot. I am told the only type I can use is a speed pot. But none available at 10k only 5k. The has 0-10vdc. As you turn to the left it closes the valve and to the right opens it. It needs to be somewhat sensitive. Can this be done with Arduino
    Thanks
    Charlie

  • @mohammedfarhat325
    @mohammedfarhat325 7 лет назад

    The codes are easy to understand

  • @ehkaptan
    @ehkaptan 4 года назад

    you are king.thanks king

  • @princening679
    @princening679 4 года назад

    Sir if we move forward joy forward arm should move forward even joystick come to original position code please

  • @teedee9393
    @teedee9393 6 лет назад

    Does the battery need to be connected directly to the breadboard, or can I connect it via the Arduino's power port?

  • @scara6709
    @scara6709 3 года назад

    can i connect two joysticks to the 9v and the gnd of the battery?

  • @pepmichael9045
    @pepmichael9045 7 лет назад

    Can I ask you some question? Why does some of my servo rotate 360 degree? Thx. for tutorial. It's easy to understand :)

  • @Goose-zg3fu
    @Goose-zg3fu 3 года назад

    thx it works great!

  • @pasindudrawings8936
    @pasindudrawings8936 4 года назад

    It works.thank you

  • @---is8zn
    @---is8zn Год назад

    Thank you for such great code algorythm and so detailed comments //.... may god-machine bless you with his divine wisdom

  • @lookyloo777
    @lookyloo777 7 лет назад +2

    I would like to know can that be made to handle a LARGE stepper motor,just on one axes(back and forth )

  • @Lot10Games
    @Lot10Games 4 года назад

    Is it ok to connect to 5V of the arduino board a 9V battery? The VIN pin is more suitable for that... I think .Cool video

  • @samopal11
    @samopal11 7 лет назад

    GOOD video!.. can you make it with nfr24l01 please??...

  • @Sergio-bi1oq
    @Sergio-bi1oq 6 лет назад

    hello it can be the same but that the Joystick is for remote remote control

  • @azemhenrijoel7207
    @azemhenrijoel7207 6 лет назад

    best tuto

  • @KIVPush
    @KIVPush 6 лет назад +2

    Hello, wonderful video. I built one with 4 servos. 2 servos are controlled if the button is not pressed. The other 2 are controlled when the button IS pressed. I can only control the second 2 when the button is pressed and held down. Is there a way to write a code so each time you click the button it switches back and forth between each servo set? Like if I click the button and then release it, it switches to one set. If I click it again and release it, it switches back to the first set. Is there a way to do this?

    • @JustinS06
      @JustinS06 2 года назад +2

      I know I'm late, but for those looking for the same thing here it is:
      First of all, it's really easy. You just need a boolean which is either True (1st mode) or False (2d mode).
      At the start of loop(), check if the button has been pressed, if so do this:
      bool Mode = True// True will be the 1st mode and False is the 2d mode.
      void loop(){
      if (the button has been pressed)
      Mode = !Mode // Doing this sets mode equal to the opposite of mode. So: if it's True, it will be False and vice versa.
      // check if Mode is true, if so, control the first 2 servos
      // check if Mode is false, if so control the last 2 servos
      }

  • @vijraw5744
    @vijraw5744 4 года назад

    Awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!!