# How to Code Step Motor

In this project we will learn how to use step motor with code.

• 503 views
• 11 respects

## Components and supplies

 Jumper wires (generic)
×6
 Arduino UNO & Genuino UNO
×1
 Step motor with driver
×1

## Apps and online services

 Arduino IDE

### Applications

In first we must know that Step motor are much more accurate than normal or servo motors.

So they're used in objects which need precision like 3D printers.

But they're slower than other motors.

### Operation

The step motor, shown on the right, is made of a magnetic rotor (in grey) with two poles, north and south, as well as a double stator (one part in blue, the other in green): Each of these two parts is associated a winding with a midpoint and two phases.

By feeding either phase, the magnetization can be inverted at the corresponding stator level.

Stator / rotor : The stator is the fixed part of a rotating machine. The rotating part of a machine, called a rotor, rotates normally in the stator. Examples of such machines are pumps and motors.

Definitions sources : Wikipédia

### Connections :

9 ( Arduino ) ---> 1N1 ( Motor driver )

11 ( Arduino ) ---> 1N2 ( Motor driver )

10 ( Arduino ) ---> 1N3 ( Motor driver )

6 ( Arduino ) ---> 1N4 ( Motor driver )

12V+ ---> 5V ( Arduino )

5V- ---> GND ( Arduino )

After you have just to set the extremity of the motor wires in the white multipins connector.

For the code, we use the Library <Stepper.h>. Personally, I haven't had to download it, but I you don't have the library : https://github.com/arduino-libraries/Stepper

## Code

##### Step motor .inoArduino
```#include <Stepper.h>

int numberofstep = 48*64;

Stepper motor(numberofstep,9,11,10,6);    // we use pins 9, 11, 10, 6
void setup()
{

motor.setSpeed(9); // we set motor speed at 9
}
void loop()
{
motor.step(600); // the motor will run during 600 step (you can change the step)
motor.step(-800); // the motor will run during 800 step in reverse (you can change the step)

}
```

• 6 projects
• 7 followers

December 8, 2018

#### Members who respect this project

and 5 others

See similar projects
you might like

• 8,831 views
• 37 respects

• 18,249 views
• 48 respects

• 10,319 views
• 1 comment
• 31 respects

• 6,724 views
• 26 respects

#### Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

• 5,708 views