Figure 1 L298N Dual H-Bridge connected to a bi-polar stepper motor.
Interface Arduino Controlling L298N H-Bridge Motor Control
Earlier we looked at L298N Motor Controller Theory and Projects to understand the basic operation of the L298N dual H-bridge motor controller. In this section I've connected the L298N to a bi-polar stepper motor and connected it to the Arduino micro-controller. Note the motor voltage is the voltage rating of the stepper motor up to 40 volts and a current limit of four amps.
Note the motor voltage will have to doubled. For example if a unipolar motor is rated at 5-volts then in the bipolar mode will be 10-volts. This is due to the coils being operated in series.
The Arduino series of micro-controllers are an outstanding value for the hobbyist and student to learn the basics of programming and interfacing micro-controllers. In this example in both hardware and programming the code below will operate the stepper motor through the L298N.
The steppers I used in the example are all 7.5 degrees per-step and require 48 steps to go 360 degrees. Stepper motors are very accurate and often don't need feedback to tell position.
A bi-polar stepper motor has only two coils and operates by reversing the polarity unlike a unipolar stepper motor that operates by switching four coils on/off.
Here we have used only three connections to the Arduino micro-controller to operate the stepper motor. We tied ENA and ENB together and used two inverters from a 74LS04. We could still leave ENA and ENB separate if one wishes. In the program below simply remove any statements relating to ENB, yellow, or black which will free up three digital pins. It would also be a good idea change "#define orange 11" to #define orange 10" then wire digital pin 10 to IN3.
Download the Arduino code l298n_arduino.txt copy and past to the Arduino compiler.
Shown above is a pre-assembled board I bought off Ebay for $8 with shipping. This included power connectors, diodes, LED indicators, and even a 5-volt regulator. This is in my opinion the smart way to go to save time, money, and effort.
- Arduino Stepper Motor Coil Winder
- Considerations for Using Stepper Motors
- How to Connect Easy Driver Micro-Stepper Controller to Arduino
- Using a Unipolar Stepper Motor with a Arduino
- Using the MC3479 Stepper Motor Controller with Arduino
- Connecting the Arduino to a L298N H-Bridge
- L298N Motor Controller Theory and Projects
- Arduino stepper motor control YouTube
- Using Hall Effect Switches and Sensors
- Basic Transistor Driver Circuits for Micro-Controllers
- Opto-Isolated Transistor Drivers for Micro-Controllers
- Build a H-Bridge Motor Control with Power MOSFETS
- Connect Arduino to LCD Display with 74164 Shift Register
- Arduino with LCD Display and DS18B20 Temperature Sensor
- Below has differing code from the above. Works the same.
- Arduino with LCD Display and DHT11 Temperature-Humidity Sensor
- In Depth Look at AC Power Control with Arduino
- YouTube Video for Arduino AC Power Control
- Four part series:
- Experimenting with the PCA9555 32-Bit GPIO Expander with Arduino
- PCA9555 32-Bit GPIO Expander with Arduino and a 4X4 Keypad
- PCA9555 32-Bit GPIO Expander with Arduino Using Interrupts
- PCA9555 32-Bit GPIO Expander with Arduino and LCD Display
- YouTube Video for Series
- Rotary Encoder Used with Arduino Interrupts
- Connecting Arduino to a 74C164 Shift Register
- Using the Mc3479 Stepper Motor Controller with Arduino
- Build a Thermocouple Amplifier
- My YouTube Channel