Home Code Stepper motor example

Stepper motor example

by shedboy71

In this example we will show a basic stepper motor example, we use a driver board that can be bought on many sites which basically comprises of a ULN2003 IC and a few other components, you can use either 5v or 12v, the motor that comes quite often with this board is a 5v type, you can see it further down the page.

Here is the board that I used for this example and here are the connections

Arduino pin 8 -> IN1
Arduino pin 9 -> IN2
Arduino pin 10 ->IN3
Arduino pin 11 -> IN4

stepper motor board

stepper motor board

Here is the motor I used, the motor connector can only fit one way on the board. This is identified as a 28byj-48 type.

stepper motor

stepper motor

Code

The code uses the built in stepper library, this is a fairly basic exampl

[cpp]

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

int stepCount = 0; // number of steps the motor has taken

void setup() {

}

void loop() {
// step one step:
myStepper.step(1);
stepCount++;
delay(100);
}

[/cpp]

Links
5V 4-phase Stepper Motor+ Driver Board ULN2003

Share

You may also like