# Stepper Motor

![](/files/KWyh4CkPqEqSI3ZB3zY0)

### Component Required:

1 x Arduino Uno R3

1 x 830 tie-points breadboard

1 x ULN2003 stepper motor driver module

1 x Stepper motor

1 x 9V1A Adapter

1 x Power supply module

6 x F-M wires (Female to Male DuPont wires) 1 x M-M wire (Male to Male jumper wire)

#### Stepper Motor:

A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence.

The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied. One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control means no feedback information about position is needed.

This type of control eliminates the need for expensive sensing and feedback devices such as optical encoders. Your position is known simply by keeping track of the input step pulses.

#### **ULN2003 Driver Board**

![](/files/MI1SKk8YC0FCgmXFcppz)

### **Connection Diagram:**

![](/files/b0PZwdN57GPgnUUMkJqP)

### **Wiring schematic:**

![](/files/8WaA3MblSbQ0daNcgItT)

### **Code**

After wiring\*\*,\*\* install the **Stepper.zip** library

{% file src="/files/KkSmC4LzHZVhvYCTraO2" %}

```
#include <Stepper.h>
const int stepsPerRevolution = 1500;
// change this to fit the number of steps per revolution
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup()
{
  // set the speed at 20 rpm:
  myStepper.setSpeed(20);
  // initialize the serial port:
  Serial.begin(9600);
}
void loop() { // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);// step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution); delay(500);
}
```

{% file src="/files/POUzphZsMyklb2OSIirG" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.arduinosa.co.za/arduino-kits/basic-starter-kit/stepper-motor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
