LabVIEW Interface for Arduino Documents

Showing results for 
Search instead for 
Did you mean: 

L298 Stepper Driver

This example demonstrates the use of a L298 IC for driving a stepper

motor.  It does not use LIFA.

Attached is a zip file that contains 3 files for demonstrating the

operation of the L298 IC.  The files in the zip file are a

L298vers2 sketch, a L298N stepper.VI and a X Running Sum.VI. 

For the wiring  between an Arduino Uno and a L298 IC use the wiring

diagram shown on this page.


For the wiring between a L298 IC and a Bipolar stepper motor

use the wiring diagram shown on this page.


For the wiring between a L298 IC and a Unipolar stepper motor

use the wiring diagram sown on this page.



The sketch is configured for a 200 steps per revolution step motor.

If your step motor has a different number of steps per revolution

change the code in the line that says "#define STEPS 200" to match the steps

per revolution value for your motor.  Next compile and download the

sketch to your Arduino board. You can test the sketch by using the

Arduino Serial Monitor.  Enter a positive integer in the Send text

box and press Send.  The step motor should start rotating.  The

number of steps the motor makes will be equal to the value of the

integer you sent.  To reverse the direction of rotation send a negative



To use the L298N Stepper.VI and X Running Sum.VI

Set Serial Port to the same COM port you used when downloading the

sketch to the Arduino board.

Set X Step Setpoint to the number of steps you want the step moor

to move.

Run the VI

Momentarily press the the Send Switch.

The stepper motor should start rotating.

The X step Position indicator is a running sum of the number of

steps the step motor has moved during a session.

Member Zahkay

Dear Sir 


This is a very good job..  the arduino coding is not similar like mine but even though it is the same concept use. I also used L298. But Sir when i run the VI and then connect my USB cable which is in the com port.

now there is a problem, when i run it, the serial port is recognise as the port i put the USB

and when i try to put a step

it does not work

Y sir

when i press the on-off button, the counter for the x position increases

can u please help me sir

Active Participant hrh1818
Active Participant

Before you tried the example with Labview did the stepper motor rotate when you used the Arduino serial monitor to test the sketch?  If not check the wiring.  Are you suppling power for the ste[pper motors from a separate power supply?   What voltage are you using and the cutrrent rating of the power supply?


Member Zahkay

Yeah sir, it work with the arduino code i did. It does one revolution clockwise and another revolution anticlockwise. I even try to do the coding with switches so as to be able to position it properly.

yeah i am supply 12 V seperate power supply with 2 Ampere. ( i bought a specific power supply of 12V).

what could be the reason sir

should i post my circuit along with the coding

Active Participant hrh1818
Active Participant

What do you mean when you say "I even try to do the coding with switches so as to be able to position it properly."?

Try stopping and restarting the VI 2 or 3 times. 


Member Zahkay

hmm instead of using a labview vi so that i am able to insert the steps and then it will rotate, this am not able to do.Smiley Sad even though i did try with LIFA. this is what i mean

yeah i did try again and again

i wanted to ask u. when u do your circuit, u did upload the arduino code. n test it

then after u open the labview VI and

does it work?

Active Participant hrh1818
Active Participant

Yes, I down loaded the L298Stepper Driver example this morning, ran it and the example still works.  My next suggestion is to use PortMon to monitor the data sent between the VI and Arduino. However, I have higher priority things that I am working on and will not be able to help you again until after the 19 of April.  PortMon is available here <>.  You may want to run the program to see if it provides any clues as to the why L298 Stepper.VI doesn't work for you.


Member Zahkay

okie sir, i am sorry to disturb you. i did try , it works and the stop. i dont know where is the problem.thank you.

i will check that link you send me.