How to Code Step Motor

How to Code Step Motor

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

  • 770 views
  • 0 comments
  • 14 respects

Components and supplies

Apps and online services

About this project

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)

}

Comments

Similar projects you might like

Motor controlled with Arduino

by Benjamin Larralde

  • 18,249 views
  • 20 comments
  • 48 respects

Arduino Morse Code Machine

Project showcase by Vlada Krsmanovic

  • 10,597 views
  • 1 comment
  • 31 respects

Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

  • 6,864 views
  • 9 comments
  • 34 respects

Control the Speed of Brushless DC Motor Using Bluetooth

Project tutorial by mohitmehlawat

  • 3,487 views
  • 0 comments
  • 13 respects
Add projectSign up / Login