Stepper motor + Driver Uln2003 in arduino

in #utopian-io7 years ago (edited)

In this article I Will Show You How To Drive Stepper Motor With Arduino, I have a stepper motor with motor driver Uln2003 The rotation angle of this motor is proportional to the input pulse and this motor has full torque at standstill(if the windings are energized) Precise positioning and movement since stepper motors have an accuracy of – 5% of a step just like the cheap stepper motors out there, Since i have the driver for the motor it is easy to make a circuit on it.

20180108_182254.jpg

COMPONENTS NEEDED

20180108_161724.jpg

  • Driver Uln2003 
  • stepper motor
  • Breadboard/ optional
  • Uno board
  • male to female jumpers
  • CIRCUIT DIAGRAM

    steppermotor.png

    Using a breadboard here is optional, beacause theres only 2 wires will be connected on it the 5V and the GND of the motor, so i connect it directly to the arduino board.

    20180108_162415.jpg

    Connect the + sign on the motor driver to the 5V and the - to the GND on the arduino board

    20180108_162819.jpg

    Connect all the IN pins to the digital pins on the arduino, theres only 4 pin so IN1 to the 8, IN2 to 9, IN3 to 10, and the IN4 to the digital pin 11, so thats the circuit.

    SOFTWARE

    Before we work on our sketch, make sure to download the Arduino IDE for your specific operating system. I’ll leave a link to where you can download this software: https://www.arduino.cc/en/Main/Software

    seq1.png

    Arduino Sketch code for Stepper motor;

    steeeep.png

    Copy the CODE here:

    #define IN1  8
    #define IN2  9
    #define IN3  10
    #define IN4  11
    int Steps = 4096; //4096 or 768
    int cstep = 0;

    void setup()
    {
      Serial.begin(9600);
      pinMode(IN1, OUTPUT); 
      pinMode(IN2, OUTPUT); 
      pinMode(IN3, OUTPUT); 
      pinMode(IN4, OUTPUT); 
    }

    void loop()
    {
      for(int x=0;x<Steps;x++)
      {
      step1();
      //delay(1);
      delayMicroseconds(2500);
      }
      Serial.println("Boom!!");
      delay(1000);
      
    }

    void step1()
    {
      //stepp
      switch(cstep)
      {
       case 0:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, HIGH);
       break; 
       case 1:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, HIGH);
       break; 
       case 2:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, LOW);
       break; 
       case 3:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, LOW);
       break; 
       case 4:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break; 
       case 5:
         digitalWrite(IN1, HIGH); 
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break; 
         case 6:
         digitalWrite(IN1, HIGH); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break; 
       case 7:
         digitalWrite(IN1, HIGH); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, HIGH);
       break; 
       default:
         digitalWrite(IN1, LOW); 
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break; 
      }
       
       cstep=cstep+1;
       if(cstep==8)
         {cstep=0;}
    }

    Connect the arduino uno to your computer then verify compile then upload it to the board. so this is the result.

    20180108_163611.gif

    So thats it! if you wan to know how to program arduino this blog by the way i was inspired by the circuit here i just make some changes on the circuit bcoz its seems like the 5v and GND is connected to the same rail on the breadboard, i hope this post might help you thank you for passing by, please follow me @pakganern

    20180105_182452[1].jpg



    Posted on Utopian.io - Rewarding Open Source Contributors

    Sort:  

    Thank you for the contribution. It has been approved.

    • However, please make one improvement. The code should come in one single code block. Just use ``` on the line before and after the start of your code. Go to any guide for markdown and learn this!

    Example:

    1 line
    2 line
    3 line
    

    You can contact us on Discord.
    [utopian-moderator]

    noted thanks

    Hey @pakganern I am @utopian-io. I have just upvoted you!

    Achievements

    • This is your first accepted contribution here in Utopian. Welcome!

    Suggestions

    • Contribute more often to get higher and higher rewards. I wish to see you often!
    • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

    Get Noticed!

    • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

    Community-Driven Witness!

    I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

    mooncryption-utopian-witness-gif

    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

    Coin Marketplace

    STEEM 0.16
    TRX 0.17
    JST 0.029
    BTC 69681.50
    ETH 2514.53
    USDT 1.00
    SBD 2.55