
In this tutorial, we will build a Step Motor using an Arduino Uno.
What You Need
- Arduino Uno
- USB 2.0 Cable
- Step Motor (We used ROHS STEP MOTOR 28BY-48 5V DC)
- Male/Female Wires
- Female/Female Wires
- L293D Motor Driver
Hardware Setup
The Arduino Uno is perfect for this project because it has a voltage power of 5V, just like the Step Motor, and also because it contains the built in IC Circuit. Begin by connecting the four wires in the Step Motor to the L293D Motor Driver. Then, connect the L293D Motor Driver to the Arduino Uno as follows:

Next, we connect positive to power and negative to ground. Arrange the wires as follows:

You will see that below the + and - symbols on the L293D: 5 - 12V. This is the voltage range for the L293D. We will be working with 5V, so we are good to go!
Before the Code
Connect your USB to the Arduino Uno and your computer. To compile and run the code for this tutorial, we will be using the Arduino IDE. You can download the latest version here.
In Arduino, navigate from Tools
to Board
and select Arduino Uno
. Then, choose your port: Tools
> Port
and choose the correct USB port. The port name may look strange, but that's normal.
The Code
Copy and paste this code into your sketch:
#include <Stepper.h>
const int stepsPerRevolution = 512;
//initialize library on pins
/* Notice that the middle pins are out of order. The sequence for the inputs of this motor
is actually 1, 3, 2 ,4. This is detailed in the datasheet for this piece of hardware.
Since we arranged our pins in sequential order, we switch around the middle pins to mimic the pattern.
*/
Stepper myStepper(stepsPerRevolution, 8, 10, 9 , 11);
void setup() {
//speed at 60 rpm
myStepper.setSpeed(60);
//initialize serial port
Serial.begin(9600);
}
void loop() {
//turn clockwise
Serial.println("clockwise");
myStepper.step(1);
}
Click Upload
and see your Step Motor begin to turn! The Arduino IDE will help you experiment more with the stepper. Navigate to File
> Examples
> Stepper
to view the sample code provided by the Arduino IDE.
Trouble Shooting
- Check that you selected the correct board
- Check that you are using the USB port
To take this one step further, connect your device to Wia and add Commands and Flows. If you have any questions, reach out to us using the chat icon at the bottom right hand side of our site!