Control a Stepper Motor using an Arduino, a Joystick and the Easy Driver - Tutorial

1,360,786
0
Published 2015-05-13
Let's see how to control a Stepper motor with an Analog Joystick using an UNO and the Easy Driver motor driver.
Check out our tutorials page at : brainy-bits.com/tutorials/ to get the schematic and more information on this tutorial.

All Comments (21)
  • @ivangutowski
    The way you talk throught he code is so clear. I literally now understand it all. There ahs previously been so much I don't understand that it's all alin and I can't follow, but you talking through each bit made sense.. SOOOO good
  • @selimshakur3189
    Thanks for the video, you explain really well. I work on a project : an automated stockage cupboard. Basically, I have a similar X axis and a Y axis a little bit different built on the X one to allow 2D movements. These explanations may be really usefull for me since I learnt python but not arduino language. I may give you more info when I finish the project if you want to.
  • @anthonycruz4435
    So happy to find this the store and all the other sweet stuff on your page!!!! Subscribed!
  • @SunnyWu
    That is cool! I had some trouble following the code but thanks for the tutorial. Probably have to take a closer look.
  • @12Keat12
    Thanks so much! Is there an easy way to use a 6 wire stepper motor with this driver?
  • @drunkdonutboy
    I'm trying to format a code with a keyboard control for a six degree of freedom robot and this was invaluable to me so much clearer now thank you
  • @fuzzmew
    It is good that it has good 'hold current', my older controller did not have hold current and motor would be able to be pushed out of place when not moving.
  • @FloodDickHPC
    Thanks for the video, it would be really helpful if you could do a similar one to configure a stepper motor to use it with a controller
  • wow such a nice tutorial for me, it really helpful since I do not have any experience yet with that little guy (stepper motor), keep going to make a similar project,
  • @donletter9299
    It is incredibly rude to criticize someone's pronunciation of words when all they are doing is sharing information. Please stop it! No matter where you are or what language your native language is, there are going to be variations. I have a friend in England that claims he can drive 25 miles from his home and be unable to understand what anybody is saying. However, they would all claim to be speaking "English." If you are from the states, you should understand at least the notion of different dialects, although they are more spread out. Just watch television to understand what I mean. If the presenter is not speaking their native language, but in yours, then they are making an exceptional effort to share their knowledge. The least you could do is respect that. Done with rant. BTW, thank you, Brainy-Bits, for the video. Subscribed.
  • @Dancopymus
    My question is identical to the Muaathe Aziz; I would like a program with 2 limit switches, end on the left side and end on the right side (without joystick / Potentiometer) Thanks
  • @mra3709
    thanks for your vid's , wondering how you would control 2 steppers with 1 joystick , X & Y tks
  • @user-sh3xj1hn9f
    Hello. Can you help to write a sketch for Uno to control Nema17 (a4988) from ir remote. I need nema to do few step steps forward on 1 button, and same steps backward on another button. Please, i will really appreciate if you can
  • @thisispav
    Hi there Brainy-Bits, how much weight could that motor pull? Im looking for a motor to add motion to my camera slider. I would attach the belt to the camera carriage. Do you have a video where you show the assembly? thanks
  • Looks like a great way to build a camera slide for filming YouTube videos. Hope to do that for a future project soon.
  • @teslateam7631
    hi brainy nice work...i use your tutorial to custom my video slide,work fine! but I will like controll full steps of the motor and not back to the center position when i release the joistik. If possible set the speed 'for moving from point A to point B to create time lapse using the joistik button. how can I change your sketch?
  • @harounhajem7972
    Can you save the last position when turning of the Arduino? So you can use that position as a reference next time you boot up.
  • @eixpata502
    I wish you made a closer look to the driver. However, I appreciate your work. Thank you! :-)
  • #define step_pin 3 // Pin 3 connected to Steps pin on EasyDriver #define dir_pin 2 // Pin 2 connected to Direction pin #define MS1 5 // Pin 5 connected to MS1 pin #define MS2 4 // Pin 4 connected to MS2 pin #define SLEEP 7 // Pin 7 connected to SLEEP pin #define X_pin A0 // Pin A0 connected to joystick x axis int direction; int steps = 1025; void setup() { pinMode(MS1, OUTPUT); pinMode(MS2, OUTPUT); pinMode(dir_pin, OUTPUT); pinMode(step_pin, OUTPUT); pinMode(SLEEP, OUTPUT); digitalWrite(SLEEP, HIGH); // Wake up EasyDriver delay(5); // Wait for EasyDriver wake up /* Configure type of Steps on EasyDriver: // MS1 MS2 // LOW LOW = Full Step // // HIGH LOW = Half Step // // LOW HIGH = A quarter of Step // // HIGH HIGH = An eighth of Step // */ digitalWrite(MS1, LOW); // Configures to Full Steps digitalWrite(MS2, LOW); // Configures to Full Steps } void loop() { while(analogRead(X_pin) >= 0 && analogRead(X_pin) <= 100) { if(steps > 0){ digitalWrite(dir_pin, HIGH); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps--; } } while(analogRead(X_pin) > 100 && analogRead(X_pin) <= 400){ if(steps < 512) { digitalWrite(dir_pin, LOW); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps++; } if(steps > 512){ digitalWrite(dir_pin, HIGH); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps--; } } while(analogRead(X_pin) > 401 && analogRead(X_pin) <= 600){ if(steps < 1025) { digitalWrite(dir_pin, LOW); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps++; } if(steps > 1025){ digitalWrite(dir_pin, HIGH); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps--; } } while(analogRead(X_pin) > 601 && analogRead(X_pin) <= 900) { if(steps < 1535){ digitalWrite(dir_pin, LOW); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps++; } if(steps > 1535){ digitalWrite(dir_pin, HIGH); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps--; } } while(analogRead(X_pin) > 900 && analogRead(X_pin) <= 1024) { if(steps < 2050){ digitalWrite(dir_pin, LOW); digitalWrite(step_pin, HIGH); delay(1); digitalWrite(step_pin, LOW); delay(1); steps++; } } }
  • @jayc2469
    Great little project. When you used an analogue joystick I was hoping that the motor speed would be proportional to joystick position but as it is, the motor appears to move at a fixed speed - and control could be achieved with 2 spst switches(?)