Tutorial: How to use a stepper motor (28BY-J48) with an Arduino and a ULN2003A board | UATS A&S #10

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • In this tutorial, you learn how to drive the 28BYJ-48 stepper motor with a ULN2003A driver board and an Arduino Uno.
    Written tutorial and source code: www.mschoeffler.com/2017/09/23...
    :: List of materials ::
    -- Arduino Uno
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- Jumper wires
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- Breadboard
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- 28BYJ-48 stepper motor
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- ULN2003A driver board
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    Video Chapters:
    0:00 Tutorial Introduction
    1:58 Wiring
    4:06 Programming
    5:46 Example demonstration
    Credits:
    Songs: Killing Time and Rocket Power
    Artist:Kevin MacLeod (incompetech.com)
    Licensed under Creative Commons: By Attribution 3.0 License
    creativecommons.org/licenses/...
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    Thanks for posting this. 5 years later your video got me started!

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

    Thank you, you're a star, you showed the basic code to control as stepper motor and didn't over complicate it so that I can go and do my own thing with confidence. Thank you.

  • @lucanfilm1948
    @lucanfilm1948 6 ปีที่แล้ว

    Thank you for this great tutorial - it really helped me to get into that topic.

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

    Sir ur amazing I'm from India , clarity in explanations is amazing I have followed your vedio and done project too plz continue such vedio

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

    thanks for explaining so well i understood everything!!

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

    This is a Great tutorial thank you, I have just liked and subscribed :)

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

    Great tutorial, thanks.

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

    Here's a though: desolder the 4 driver input pins from the ULN2003 and reattach to the opposite side of the board. Then you can just plug the board directly into the Arduino. Makes for a smaller package and less chance of something disconnecting.

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

    Thank you, helped a bunch.

  • @torstonvodesil6709
    @torstonvodesil6709 7 หลายเดือนก่อน

    nice and simple, thanks

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

    very helpful thank you

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

    is there a code for controlling the motor with a potentiometer like how you would control a servo motor with a potentiometer?

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

    Thanks
    Nice tutorial

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

    What are pins 5,6,&7 used for on the driver?

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

    Am I right in saying that it should turn clockwise for a minute but in your demo it's turning anti-clockwise and same when it should turn anticlock wise for ten secnds it turning clockwise? Am loosing it?

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

    Hi thank you for the tutorial, I am using the 28ybj-48 stepper motor and controlling it with hc-05 Bluetooth model from my phone, I am sending a number 1 to make him move cw and number 2 to move ccw, but I don't know what to write in the code to make the motor stop by sending let's say number 3, I am totally new to arduinos, thanks in advance

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

    thank you very very much.......

  • @glenlobo
    @glenlobo 6 ปีที่แล้ว

    Single Axis Tb6600 and RC_52002513 Stepper Motor Driver Controller Speed Regulator Pulse Signal Generator CAN I MAKE A STEPPER MOTOR WORK??

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

    Why always 8,9,10,11 pins on the arduino? Can i go for 2,3,4,5 as well?
    Thank you :)

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

    Question; if I wanted to power the motor externally, how would I do this, and what parts would be required? Any help gratefully received! :)

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

      For anyone wondering about this, you just use an external power supply of 5-12 v(depending on driver) and just share ground with power supply and arduino

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

      @Vishnu Vardhan It depends on what driver you have. You first have to check what voltage and amps you need for your motor, then based on that you pick a driver. On the driver you first need your power supply(batteries, and old stripped wall charger, cables from an old destop power suplly etc) with an capacitor tied to both plus and minus. The capacitor has to be at minimum whatever is speciffied on the datasheet of the driver. then, you need to tie the ground of the power supply to the arduino. that's it.

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

      Can I connect 9v battery to +5v in of uln2003 or it must be 5 v regulated?
      The motor is 5 volt motor, does 9volt in damage the motor?

  • @zattiya
    @zattiya 6 ปีที่แล้ว +4

    In the Stepper function: why do I do Stepper stepper(STEPS, 8, 10, 9, 11); rather than 8,9,10,11. When I change the sequence it does not move as much.

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

      The motor Is designed to be inputed in that way

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

      The stepper.h library has different sequence. 8, 10, 9, 11 fix the sequence for ULN2003

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

    Hello, can I plug this to the wall? I made a circuit and blew the board when I plugged it in

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

    Hi, thanks for the tutorial. Do you think it's possible with this motor to make a full 360deg. not in 1 mn. but 180mn? (3hours)

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

      yes you could easily do this, just have a for loop that goes up to the 2038 steps inside the loop step 1 step then have a delay (divide the 3 hours by rhe 2038 steps to find out how long a delay you need).

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

      Yes, i got this, really great, thanks

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

    can you explay why the steper motor run only ccw?

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

    Hi could you tell me how to spin the engine at 30 or 60 rpm if this is posible? sorry english isn´t my first language

    • @mschoeffler
      @mschoeffler  6 ปีที่แล้ว

      To be honest, I can't remember whether I did test 30 or 60 rpm. But i guess this should be possible. For 30 rpm just write "stepper.setSpeed(30);" in the loop function and you are ready to go.

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

      15rpm is 28BYJ-48 reliable designed speed, for faster speed it may not step accurately, if you raise the voltage for higher speeds there will be heating problems, so you may need to use a different stepper motor like www.adafruit.com/product/918 for 60rpm speed.

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

    hello, how much weight (kilos) can this motor lift? thanks

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

    So very informative.
    I thought pin 8 on an UnO was not PWM.

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

    I have same stepper motor,
    Then I write that code to my IDE,
    But my stepper motor didn't spin reverse after 1 minute spin.
    What's wrong? Please help

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

      Switch pin2 with pin3 from the driver

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

      Eeeh? Which pin? Sorry i'm forgot to say that, I am using Wemos D1 R2 for this

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

    Thanks

  • @rramirezx8738
    @rramirezx8738 6 ปีที่แล้ว

    Why put the number 2038, where does that number come from?

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

      depends from the type of stepper motor. 2038 is the exact number of steps that that the rotor of that motor must do for obtain complete 360 degrees of the external shaft.
      consider that it's a geared motor, so changing the number of the teeth of the gears will change the numer of steps to do for a complete revolution.

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

      ​@@ClaudioFontachannel but why 2038? 64*64=? 4096 I think

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

      @@blue_name_warrior no. you don't have to calculate that number. It's given in the datasheet of the motor. Every motor has a different number of steps for a revolution. Consider also that that kind of motor is geared, so more teeth on the gear, more steps for a revolution; less teeth, less steps. Clear?

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

      @@blue_name_warrior You find all the details in the written article: www.mschoeffler.de/2017/09/23/tutorial-how-to-drive-the-28byj-48-stepper-motor-with-a-uln2003a-driver-board-and-an-arduino-uno/

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

    Like

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

    it has 2048 steps in full rotation, not 2038

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

      Hi Alexandru, Thank you for the comment! I made this tutorial a very long time ago, so I can't remember all the details:
      I still think that 2038 is correct, even though the datasheet and other tutorials refer to 2048. When I started to work with the stepper, I recognized that it is not as accurate as I expected. So I had a deeper look into the problem. It turned out, many others had the same problem.
      Long story short: the actual gear ratio is approximately 63.68395:1 (instead of 64 --> 32 * 63.68395=2037.8864). You find more details in my written article: www.mschoeffler.de/2017/09/23/tutorial-how-to-drive-the-28byj-48-stepper-motor-with-a-uln2003a-driver-board-and-an-arduino-uno/
      Here is an older discussion in the Arduino forum which comes to the same conclusion: forum.arduino.cc/index.php?topic=71964.0
      There are also some reports that there are differences in-between individual 28BYJ-48 motors.
      Also the example video in the video does a full rotation with 2038.

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

      @@mschoeffler I don't want to argue with you, because I see your are well informed, but I let it run couple of minutes with 2038 steps set in the code and mine was not at the start position.
      PS: Sorry for my bad english...

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

      I did not intend to argue :) Just wanted to give a detailed answer since the "2048 steps info" comes up a lot. According to the datasheet, the information is also correct. However, many stepper motors of this type do a full rotation only with 2038 steps.

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

      @@mschoeffler maybe mine is different

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

      @@mschoeffler 2048 appears quite accurate to be complete revolution. 2038 or even 2044 tends to shift (incomplete revolution).

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

    chat

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

    Hi michael... i was wondering if you could kindly help me out with this Arduino servo, stepper motor setup that i am trying to use. i would so much appreciate it if you are able to work out what is going on wrong with the code or hardware......thanks in advance...... th-cam.com/video/fis-qX9ldlg/w-d-xo.html
    here is the code that i am trying to use with the servo and stepper motor. can you see anything wrong with the code?
    #include
    #define STEPS 32
    Stepper stepper(STEPS, 9, 11, 10, 12);
    int randomRotationFrom = 5;
    int randomRotationTo;
    int randomNumber;
    int randomDelay;
    int eyes = 7;
    int angle = 10;
    int mouthclosed(-600);
    int mouthopen(600);
    int mouthspeed = 950;
    void setup()
    {
    servo_neck.attach(8);
    servo_neck.write(90);
    pinMode(eyes, OUTPUT);
    digitalWrite(eyes, LOW);
    randomSeed(analogRead(A0));
    stepper.setSpeed(300);
    stepper.step(mouthclosed);
    delay(200);
    digitalWrite(eyes, HIGH);
    delay(50);
    digitalWrite(eyes, LOW);
    delay(50);
    digitalWrite(eyes, HIGH);
    delay(50);
    digitalWrite(eyes, LOW);
    delay(50);
    digitalWrite(eyes, HIGH);
    delay(5);
    digitalWrite(eyes, LOW);
    delay(100);
    digitalWrite(eyes, HIGH);
    delay(50);
    digitalWrite(eyes, LOW);
    delay(50);
    digitalWrite(eyes, HIGH);
    delay(500);
    digitalWrite(eyes, LOW);
    delay(50);
    digitalWrite(eyes, HIGH);
    }
    void loop()
    {
    randomDelay = random(10,3000);
    randomRotationTo = random(40,140);
    randomNumber = random(1,9);
    if (randomRotationTo > randomRotationFrom)
    {
    for(angle = randomRotationFrom; angle < randomRotationTo; angle += 1)
    {
    servo_neck.write(angle);
    delay(20);
    servo_neck.write(angle - 3);
    }
    if (randomNumber == 5)
    {
    stepper.setSpeed(mouthspeed);
    stepper.step(mouthopen);
    stepper.step(mouthclosed);
    }
    }
    if (randomRotationTo < randomRotationFrom)
    {
    for(angle = randomRotationFrom; angle > randomRotationTo; angle -= 1)
    {
    servo_neck.write(angle);
    delay(20);
    servo_neck.write(angle + 3);
    }
    if (randomNumber == 5)
    {
    stepper.setSpeed(mouthspeed);
    stepper.step(mouthopen);
    stepper.step(mouthclosed);
    }
    }
    randomRotationFrom = randomRotationTo;
    delay(randomDelay);
    }