Control Stepper Motor with Arduino - Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ธ.ค. 2018
  • today i will guide you how to control a stepper motor with an arduino and a4988 stepper driver,
    we will see how to control its rotation speed with a potentiometer, and change its direction of rotation with a push button.
    components we will need;
    a stepper motor,
    an a4988 stepper motor driver,
    an arduino board,
    a 100k potentiometer
    push button
    100mf capacitor
    breadboard and connecting wires.
    i have also written a code to run the motor on various speeds using a potentiometer to adjust the motor speed.
    you will find all the diagrams and arduino files here:
    goo.gl/15Ebo5
    NOTE: arduino code is in folders above schematics :)
    buy stepper motors for cheap here:
    Stepper Motor NEMA 17: goo.gl/1zBdXx
    buy links for parts:
    (Global):
    Arduino UNO micro USB version: goo.gl/RNZS5Z
    Stepper Motor NEMA 17: goo.gl/L17oRL
    A4988 Driver: goo.gl/bcL5kZ
    Potentiometer 100Kohm: goo.gl/adwtoJ
    India:
    Arduino UNO: bit.ly/31I0FQf
    Stepper Motor NEMA 17: bit.ly/3mUykOU
    A4988 Driver: bit.ly/4br5Lj4
    Potentiometer 100Kohm: bit.ly/3SXwNrr
    the A4988 stepper driver module has total 16 pins
    the vmot and ground pins are for the external power for the motor,
    you cannot power the motor from the arduino as it requires a minimum of 8-35 volts
    i use a 12 volts 2 amp external power supply. make sure you use a decoupling capacitor to avoid any unnecessary noise.
    the next 4 pins are of the stepper motor.
    you have to connect the pins with the right polarity, otherwise your motor wont work and make loud noises.
    you can determine the polarity of the motor using your multi-meter
    Each pair of same phase should have no resistance when measured with a multi-meter, so you have to check the pairs which have zero resistance
    and connect positive and negative of phase A to 1a and 1b, and accordingly for phase b
    it is better to check the polarity in the manufacturer information for your motor to avoid this hassle.
    you can also connect multiple stepper motors for similar actions in parallel until you do not exceed the current limit
    next you have to connect the reset and sleep pin to activate the driver.
    the a4988 uses 3.5-5 volts power so you can power it from the arduino 5v output
    connect the digital4 pin of the ardiuno to the direction pin and d3 pin to step pin of the driver.
    the ms1,2,3 pins are for enabling microstepping.
    you can connect 5 volt input to the pins to enable microstepping. there are 5 different modes for micro-stepping as shown in the table.
    it is also important to limit the current to the motor.
    you can do so by setting the potentiometer on the driver to around 30 degrees clockwise for 0.5 amps
    first we will run a simple code to run a full rotation and pause for 1 second.
    upload the code and you see the motor running.
    if not,make sure you have connected all pins correctly. and followed all the procedures
    i have also written a code to run the motor on various speeds using a potentiometer to adjust the motor speed.
    you have to connect the potentiometer wiper pin to a0 pin of the arduino, and connect 5v input in the first, and ground the third pin
    i have another code in which you can toggle the direction of the motor using a push button.
    hope you enjoyed the video, please do like share and subscribe, and thanks for watching!
    Solder Iron i Use: bit.ly/2GSArih
    Helping Hand Magnifier: bit.ly/2Uh11oe
    check out my other projects:
    DIY Lab Bench power Supply: • How to make Simple Lab...
    DIY Dremel Tool: • DIY 3D Printed Dremel ...
    Arduino 3D Printer : • How to Make 3d Printer...
    DIY on off Timer: • DIY Arduino Programmab...
    DIY Quadcopter: • How To Make Drone At H...
    #steppermotor #steppermotorcontrol #steppermotortutorial #howtocontrolsteppermotor
  • แนวปฏิบัติและการใช้ชีวิต

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

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

    Again, a great How-To!
    After some double, triple and quadruple checking of the provided Nema17 to driver cables, I got everything setup, loaded your sketch and successfully tested all eight Nema17 steppers and all eight A4988 driver boards. All good to go for a future project!
    Thx, this was much simpler than testing with the CNC Shield. Now if something isn't working, I'll know it is the CNC Shield or the coding and not the Nema17s or A4988s.

  • @dhageakshay
    @dhageakshay 2 หลายเดือนก่อน

    Thanks a lot for this video, i searched a ton of videos before but non of them were this easy to understand, also the code provided is so simple yet works so fine, thanks a ton for making this video

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

    Great! I ordered eight Nema17 steppers and some driver boards and I was looking for a quick setup to test them before shelving them for now.

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

    Best video I have watched on this subject and I have watched quite a few! thank you

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

      Glad it was helpful!

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

    Brilliant! I have an Arduino gathering dust which was a gift and I just took my old Umax Powerlook SCSI scanner apart which has two large belts driven by stepper motors. I reckon I could make a really smooth camera track with this which would be ideal for product photography.

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

    Ty very much. Exactly what I was looking for 🤗

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

    Thank you very much for the very informative video. I will give this a shot.

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

    Omg this video super helped me. Thank you

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

    Finally got my code to work with yours I tried about 10 others..thanks so much!! I bashed together the code from the button one and the speed one and made it reversable, so thanks a bunch!!

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

      Hello, how do I combine the two codes? I can not. Thanks

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

      @@lendines add the relevant code to the same function.

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

      @@maddercat Hello, I'm sorry to bother you but I can't program it, if I program individually it works fine, but I can't make potentiometer and change of direction work together in the same code, I need help. Thanks.

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

      @@lendines you probably also need to add the different variables did you do that?

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

      @@maddercat Hello!!!! Thank you very much for your help, I already have it working correctly.

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

    very helpful project. Many thanks for excellent tutorial

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

    You saved my life on 14 dic 2018 and you didn't know. THANKS A LOT

    • @SuperbTech
      @SuperbTech  4 ปีที่แล้ว

      How?

    • @sobreviviendoalau8499
      @sobreviviendoalau8499 4 ปีที่แล้ว

      @@SuperbTech I'm designing a THC controller for a router based on a laser sensor, I needed this.

  • @Nico-pb1sr
    @Nico-pb1sr 7 หลายเดือนก่อน

    Fantastic how to. Electrical engineering is intimidating to me as a hobbyist, so I appreciate you providing both a what to do and why its done that way, like when you explained why the motor needs a separate power supply and recommended specific power, you saved me plenty of anxiety. Thanks again!

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

    hi first Thanks for this instructive video and a question ?? If I want to design this project in Proteus What should I do

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

    thanks alot, with button how to set defined rpm? and how to stop if i need 1 cycle only...spin CW max rpm> push button(limitswitch)> Spin CCW max rpm >then stop

  • @sculptory
    @sculptory 4 ปีที่แล้ว

    Hi friend!! Very well! Thanks! Is it possible to connect at the same time a potentiometer, a button to stop and a screen 1602 with I2C

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

    Thank you so much man!

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

    Thanks for helping 😊

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

    All right thanks for the tutorial I have a question can the motor driver power to stepper motors at the same time thank you have a good day

  • @bogdanarvatu5863
    @bogdanarvatu5863 11 หลายเดือนก่อน

    Good tutorial very simple for beginners like me😂

  • @KurioTechSphere
    @KurioTechSphere 4 ปีที่แล้ว

    Like in ur this video as u change the speed with scre driver exactly wat i want is a knob to change the speed but motor should start rotating when i use joy stick to move them

  • @iqbalsingh8086
    @iqbalsingh8086 4 ปีที่แล้ว

    Nice job .so can u help me about the coding and programing to make a electric deviding indexer with stepper moter for 40:1 ratio to make any index

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

    Can you combine the direction button and potentiometer ino's into a single ino? some of us are not able to get it working :)

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

    nice bro can you tell me how to control stepper motor using flysky module or what should be the code for it

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

    Hi guys. What is the max resolution (micro steps) possible with arduino / per revolution?

  • @DemonMix
    @DemonMix 4 ปีที่แล้ว

    HI SUPERB, IS THERE A WAY YOU CAN MAKE A CODE TO USE BOUTH AT THE SAME TIME? CHANGE DIRECTION AND SPEED CONTROL? THX

  • @philipmaud8295
    @philipmaud8295 17 วันที่ผ่านมา

    Have you got the combined code for pot and switch control? I need both functions but do not know how to combine the 2 blocks of code. Any help would be appreciated

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

    Do we need more tha 12 , 2 amp power supply to run the motor at different speed ?

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

    can we change the direction using delays in the arduino code?

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

    Very nice work
    What kind of 100 uf capacitor I must buy ? thinks

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

    Good video :)

  • @Brandon-qp7gq
    @Brandon-qp7gq 2 ปีที่แล้ว

    If you were going to disconnect the arduino from usb (for example, after development, you want to run an arduino inside a project box with no laptop connected), how would you power both the arduino and the stepper? they need to share the same ground but they need different voltages. Please advise

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

    thank you bro

  • @jack.yins0405
    @jack.yins0405 3 ปีที่แล้ว +1

    may i know the program suitable to other stepper motor driver ??

  • @alexon2010
    @alexon2010 4 ปีที่แล้ว

    Very cool the stepper motor control, there is some way to control the pontecometer automatically, without me having to rotate manually! Is there any potentiometer where I can pass the value automatically?

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

      You can do that in the Arduino code.

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

      You can fully automate or add buttons, sliders and potentiometers to the code.

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

    Can I make a stepper go clockwise and anti-clockwise at various speeds and then lock so it won’t move all from one basic switch ?

  • @KurioTechSphere
    @KurioTechSphere 4 ปีที่แล้ว

    I wants to control 2 stepper motors with joy stick and speed of the motor needs to be change with another knob can u plz help me with this its my project

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

    That's what I'm looking for !
    But I already blown up an a4988 driver with 12v adapter (without capacitor) pls Help what to do ! 😅

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

    HELLO! WHAT SOFTWARE YOU USE TO DRAW THIS. VERY CLEARLY CAN YOU SAY THE NAME OF THE SOFTWARE. THANKS YOU.

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

      It is grbl controller

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

    Hello,
    I just want to run a stepper motor with Arduino and potentiometer at a continuous speed of 60 rpm. Could you please let me know the Arduino code. Thanks in advance.

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

    can i connect 12V adapter to stepper motor, will it work?

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

    how much power does a nema 17 normally need?

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

    Can we use ultrasonic sensore?

  • @reasonsml4670
    @reasonsml4670 5 หลายเดือนก่อน

    can i use DRV8825 instead of A4988?

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

    hello sir I want to ask, if the rotation of the stepper motor only I want to set 90 degrees. What code should I add to the arduino? please answer, thank you

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

      Reduce the number of steps from 200 to 100 to go from full rotation to 90° in the chide.

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

    how about controlling 2 stepper motors sir?

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

    If I put two motors in parallel, how could I control their speeds independently with two potentiometers?

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

      U need 2 drivers

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

    I want to make my motor rotate a certain angle not full and again in backwards , how should I do it , help ... IMPORTANT

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

    Is there any way i can contact you?

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

    i have uploaded to arduino but not working? what could be the mistake

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

    Very annoying, but I can not download the sketch of diagram 2 and 3. what is wrong ?? Regards, Leo

  • @josephlove8837
    @josephlove8837 4 ปีที่แล้ว

    Also, I couldn't get the stepper motor to spin any slower than 1 rev/s. Is there any way I can slow the stepper down to 1 rev/min?

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

      joseph love yes according to another video I watched this morning you just increase the delay ( in milliseconds)

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

      @@samrodian919 Hi can you share the link of that video? or the correct sequence of the milliseconds? ...thanks

  • @jugadoo-bhai
    @jugadoo-bhai 5 ปีที่แล้ว

    Dear I can't find Arduino code .
    I think u have uploaded something else on gdrive.

    • @hamedsaws
      @hamedsaws 4 ปีที่แล้ว

      its above pitcures, look like file icons

  • @hannahhelms4032
    @hannahhelms4032 5 ปีที่แล้ว

    Do you have a code for this?

    • @SuperbTech
      @SuperbTech  5 ปีที่แล้ว

      yes code is in the link in description

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

    HI THANK YOU ... ANY ONE HAS SOURCE CODE...

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

    1:58 connections

  • @promitdas4057
    @promitdas4057 5 ปีที่แล้ว

    Please share the code

    • @SuperbTech
      @SuperbTech  5 ปีที่แล้ว

      it is in the description

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

    in smae processes increasing motor speed

  • @shashankks5609
    @shashankks5609 4 หลายเดือนก่อน

    Can u send me code

  • @votonganhmeo7763
    @votonganhmeo7763 5 ปีที่แล้ว

    no see code

    • @hamedsaws
      @hamedsaws 4 ปีที่แล้ว

      above pitcures look like folders

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

    🤔😈WHER IS CODES

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

    The dreadful "music" in the background makes it very difficult to understand what you're saying.