“BtStepper” class introduction

Stepper motors are great! they’re as flexible, simple and lovely as [bt-link href=”http://arduino.cc/ ” type=”text”]Arduino[/bt-link]; and I think we can deal with them much easier than the way [bt-link href=”http://arduino.cc/en/Reference/Stepper” type=”text”]Stepper class[/bt-link] works. So I’ve developed BtStepper motor class as a part of [bt-link href=”https://github.com/behrooz-tahanzadeh/BtMicro/” type=”text”]BtMicro[/bt-link] library. The most significant difference between Stepper class and BtStepper is the method they add delay before taking each step.

Actually BtStepper class is designed to drive stepper motors only one step forward or backward! and it’s up to developer to add sufficient delay which is useful when more than one motor should rotate simultaneously.

Reverse property

In many cases the structural and logical rotation directions are opposite to each other, for example when something is elevated by a stepper, it logically suggests that the stepper should rotate in positive direction, but because of its situation you have to decrease the step number. In these conditions, reverse property of BtStepper objects, can solve this problem and change their behavior. The default value for this property is false.

Increment/Decrement operators

Talking about single step always reminds us of ++/−− operators. BtStepper utilizes them and provides a simple clear API for developer to change step number.

[bt-code title=”BtStepper”]BtStepper motorA(4,5,6,7);
BtStepper motorB(8,9);

//Set reverse property of stepper motor
motorB.reverse = true;

//Two steppers will rotate 100 step, in opposite direction simultaneously
for(int i=0; i<100; i++)