Stepper motors
Event management for Uno, Nano, Mega

Examples of wiring

See:
4-wires wiring example of a 28byj48 with a ULN2003
2-wires wiring example of a 28byj48 with a ULN2003
Wiring example with a A4988, Step, Dir and EN
Wiring example with a A4988, Step and Dir
Wiring example with a A4988, Step only
Wiring example with a TB6600, Step, Dir and EN
Wiring example with a TB6600, Step and Dir
Wiring example with a TB6600, Step only


 

MTulnStepper or MTstepStepper?

If the stepper driver is an ULN2003 (28BYJ48 stepper) or a unipolar stepper if the 4 coils are commanded directly, use the MTulnStepper object. If the stepper is controlled by an A4988, TB6600 or another driver and the command requires a STEP wire (may be DIR and EN), use the MTstepStepper object.


 

MTulnStepper

An object MTulnStepper allows you to manage a unipolar stepper motor in the background or in blocking mode. Function can be called when stopping the stepper. The stepper must be controlled by 2 or 4 coils, using for example an ULN2003. If the stepper is controlled with a step signal (dir and EN possibly) use MTstepStepper.

 

MTstepStepper

An object MTstepStepper allows you to manage a bipolar stepper motor in the background or in blocking mode. Function can be called when stopping the stepper. The stepper must be controlled by a driver. If the stepper is unipolar (controlled by a ULN2003 for example) use MTulnStepper.

 

 

 

4-wires wiring example of a 28byj48 with a ULN2003

The 28ByJ48 is wired as well as:

If we use an ULN2003 and the Arduino outputs pins are used in order:

The pins in the order of the stepper connector are 2, 3, 4 and 5 and they will have to be declared by:

// With MTobjects:
MTulnStepper Stepper(2, 3, 4, 5, ...); // Pin in order
MTulnStepper Stepper(2, 3, 4, 5);

//With Stepper.h:
Stepper stepper(2048, 2, 4, 3, 5); // Attention inversion with Stepper.h

 

2-wires wiring example of a 28byj48 with a ULN2003

MTulnStepper Stepper(4, 5, ...);
MTulnStepper Stepper(4, 5);

With this type of connections, we only use two arduino pins, but in return, we can no longer put the motor in power save by software, which is very rarely done.


 

Wiring example with a A4988, Step, Dir and EN

MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN 8, ...);
MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN 8);

 

Wiring example with a A4988, Step and Dir

MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN UNCONNECTED, ...);
MTstepStepper Stepper(pin_Step 2, pin_Dir 5);

 

Wiring example with a A4988, Step only

MTstepStepper Stepper(pin_Step 2, pin_Dir UNCONNECTED, pin_EN UNCONNECTED, ...);
MTstepStepper Stepper(pin_Step 2);

This wiring can be used if the stepper always turns in the same direction. We only use one pin of the Arduino..


 

Wiring example with a TB6600, Step, Dir and EN

MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN 8, ...);
MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN 8);

We can first reverse (for tests) A+ and A- and/or B+ and B- or the couples (A+/A-) and (B+/B-). We will take care thereafter from the "good" sens, either by software, if dir is used, either by reversing for example B+ and B-.


 

Wiring example with a TB6600, Step and Dir

MTstepStepper Stepper(pin_Step 2, pin_Dir 5, pin_EN UNCONNECTED, ...);
MTstepStepper Stepper(pin_Step 2, pin_Dir 5);

We can first reverse (for tests) A+ and A- and/or B+ and B- or the couples (A+/A-) and (B+/B-). We will take care thereafter from the "good" sens, either by software, if dir is used, either by reversing for example B+ and B-.


 

Wiring example with a TB6600, Step only

MTstepStepper Stepper(pin_Step 2, pin_Dir UNCONNECTED, pin_EN UNCONNECTED, ...);
MTstepStepper Stepper(pin_Step 2);

We can first reverse (for tests) A+ and A- and/or B+ and B- or the couples (A+/A-) and (B+/B-). We will take care thereafter from the "good" sens, either by software, if dir is used, either by reversing for example B+ and B-.

This wiring can be used if the stepper always turns in the same direction. We only use one pin of the Arduino..