Hi Guys, In this post, I will demonstrate how you can run or control 6 wired unipolar stepper motor with Arduino using L298N driver module. The unipolar stepper motor has six wired but L298N driver module has two connectors either side to connect only four wire, I will show you how you can connect and run unipolar stepper motor with L298N driver.

What is L298N driver module

Arduino is running on 5 volts and it’s current output only 500mAmp, so run any dc motor direct with Arduino, not a good idea. Here is the motor driver comes, L298N driver module works on 6 volts to 35 volts and maximum current output is 2Amp. You can run either one stepper motor or two dc motors with this driver module.
Learn How to run two DC motor with L298N driver module

Step by step video guide for stepper motor, L298N driver and Arduino

 

Stepper motor and L298N driver connection circuit diagram

stepper motor and l298n driver module connection circuit diagram arduino

Arduino code for stepper motor and L298N driver module

#include 

const int stepsPerRevolution = 200;  
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  
  myStepper.setSpeed(50);
  
  Serial.begin(9600);

void loop() {
  // step one for one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(400);

  // step one for other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(400);
}
10 Comments
  1. orion 6 years ago

    Wow I had no idea I could use an L298N as a stepper driver. Just a few fixes to your code example and it ran great!

  2. mhmoud 6 years ago

    #include

    const int stepsPerRevolution = 200;
    Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

    void setup() {

    myStepper.setSpeed(50);

    Serial.begin(9600);
    }

    void loop() {

    // step one for one direction:
    Serial.println(“clockwise”);
    myStepper.step(stepsPerRevolution);
    delay(400);

    // step one for other direction:
    Serial.println(“counterclockwise”);
    myStepper.step(-stepsPerRevolution);
    delay(400);
    }

  3. Anuradha Fernando 6 years ago

    Perfectly working ok!

    Thanks so much for sharing! I have tried with 12V 1A power supply. Also as a next step I gonna make a transistor array with 2SD1711 (which seems to be obsolete and very less expensive these days) So we can easily handle that power and heating problem.

    Also see below the data sheets for the motor I have used 23KM-C057

    http://cnc25.free.fr/documentation/moteurs%20pap/pap_nmb.pdf

    All the best!
    Anu

  4. Umer 5 years ago

    Very good example now your video motivate me to buy aurdino . Can you please tell me is it possible that if I want to rotate stepper motor to specific angle ?

    • SWAPAN KUMAR MANDAL 5 years ago

      360 degree = 200 steps

  5. Bill 5 years ago

    It is unfortunate that the L298n does not have any current control like the A4988 or other Pololu boards used in 3d printers. Some external circuitry is needed to limit the current. I will try the circuit I found here: bristolwatch.com/ele3/2a.htm

  6. deepak kumar 5 years ago

    not working #include what is the next library we have to use ??

  7. SWAPAN KUMAR MANDAL 5 years ago

    #include

  8. frank 5 years ago

    Can I use the Mks Osc Stepper Motor Driving Controller Pulse Pwm Speed Reversing Cont T8J1
    with the Arduino Uno and with my stepper motor Nema 23?
    thanks,

  9. bob schmob 5 years ago

    Does this code work with the Arduino Uno?

Leave a reply

Your email address will not be published. Required fields are marked *

*

or

Log in with your credentials

Forgot your details?