
Step the motor with constant speed as set by setSpeed(): Set the speed of the motor in steps per second: Set the maximum speed in steps per second: Create a new instance of the AccelStepper class:ĪccelStepper stepper = AccelStepper(MotorInterfaceType, 8, 9, 10, 11) Define the AccelStepper interface type: * Example sketch to control a stepper motor with L298N motor driver, Arduino UNO and AccelStepper.h library. I set it to 100, so we should see around 1.6 revolutions per second. You can set the speed of the motor in RPM with the function setSpeed(rpm). In the setup() we define the speed of the motor. Note that you can create multiple stepper objects with different names if you want to control more than one motor. The name ‘myStepper’ will be used to set the speed and number of steps for this particular motor.

Stepper liftmotor = Stepper(stepsPerRevolution, 8, 9, 10, 11). In this case I called the stepper motor ‘myStepper’ but you can use other names as well, like ‘z_motor’ or ‘liftmotor’ etc. Initialize the stepper library on pins 8 through 11: In our case these are pins 8, 9, 10 and 11. For this we use the function Stepper(steps, pin1, pin2, pin3, pin4) where steps is the number of steps per revolution and pin1 through pin4 are the pins used to drive the stepper motor. You can change this value if you want if you are using a different type of stepper motor or setup.Īfter this, you need to create a new instance of the Stepper class, which represents a particular stepper motor connected to the Arduino. This means it takes 200 steps to rotate 360 degrees. n this example we will be using the motor in full-step mode. Next we need to define how many steps it takes for the motor to rotate 1 revolution. More information about this library can be found on the Arduino website. The sketch starts by including the Stepper.h Arduino library. Step on revolution in the other direction: Stepper myStepper = Stepper(stepsPerRevolution, 8, 9, 10, 11) Define number of steps per revolution: * Example sketch to control a stepper motor with L298N motor driver, Arduino UNO and Stepper.h library. This sketch turns the stepper motor 1 revolution in one direction, pauses, and then turns 1 revolution in the other direction. Important note: remove the +12V jumper if you are using a power supply higher than 12 V. The connections are also given in the table below: L298N Connections L298N L298N motor driver with stepper motor and Arduino wiring diagram.
#L298N MOTOR DRIVER EAGLE LBR HOW TO#
The wiring diagram/schematic below shows you how to connect a stepper motor, power supply, and Arduino to the L298N breakout board. Wiring – Connecting L298N to stepper motor and Arduino Outputs of the Bridge B the current that flows through the load connected between these two pins is monitored at pin 15. TTL Compatible Enable Input: the LOW state disables the bridge A (enable A) and/or the bridge B (enable B). Supply Voltage for the Power Output Stages


Outputs of the Bridge A the current that flows through the load connected between these two pins is monitored at pin 1. The sense resistor needs to be connected between this pin and GND (not used on breakout board). If you can’t find the datasheet, you can measure the resistance of one of the windings and use the following formula to get an estimation of the current draw: Since the driver can supply a maximum of 2 amperes per channel, you need to find a stepper motor that can be used in this voltage range and doesn’t exceed the maximum current rating.Ĭheck the datasheet of your stepper motor and look for the voltage/current draw of the motor. Not all stepper motors will work! The L298N operating voltage is between 4.8 and 46 volts (max 35 V when mounted on the breakout board). What this means for you, is that you need to be careful when selecting the stepper motor and power supply to use with this motor driver.

When the motor draws too much current, you can damage the driver and the motor will get hot! This means that the current draw depends on the relationship between the inductance and resistance (L/R) of the stepper motor that you connect to it.
#L298N MOTOR DRIVER EAGLE LBR DRIVERS#
One thing that is very important to remember is that the L298 does not have an easy way to set a current limit unlike other stepper motor drivers like the A4988 ( tutorial).
