Language: EN

libreria-arduino-simplestepper

Arduino SimpleStepper Library

The SimpleStepper library implements the necessary actions to control a unipolar stepper motor, such as the 28BYJ-48. It is a convenient alternative to more complex classes like the Stepper library.

The SimpleStepper class is a simple object that only contains the step sequences. It only has two methods, CW and CCW, which advance one step in the clockwise and counterclockwise directions, respectively.

The object instance does not know the number of steps of the motor or its state. These should be controlled from a higher level.

In the constructor of the task, we can specify the desired sequence, being possible to use Halfphase, OnePhase, and TwoPhases. The default sequence is HalfPhase.

The SimpleStepper library is mainly intended to be used in conjunction with AsyncStepper, allowing you to handle multiple stepper motors with independent and non-blocking speeds easily.

User Manual

The SimpleStepper class can be instantiated as an object through one of its constructors,

SimpleStepper(uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4)
SimpleStepper(SecuenceType secuenceType, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4)

Use of SimpleStepper

// Move in the clockwise direction
void CW();

// Move in the counterclockwise direction
void CCW();

Examples

The SimpleStepper library includes the following examples to illustrate its use.

  • SimpleStepper: Example that shows how to create a rocking effect with AsyncServo
#include "SimpleStepperLib.h"

SimpleStepper stepper(SimpleStepper::HalfStep, 8, 9, 10, 11);
int motorSpeed = 1200;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  for (auto i = 0; i < 20; i++)
  {
    stepper.CW();
    delayMicroseconds(motorSpeed);
  }

  for (auto i = 0; i < 20; i++)
  {
    stepper.CCW();
    delayMicroseconds(motorSpeed);
  }
}

Installation

  • Download the latest version from GitHub
  • Unzip the file
  • Copy it to your libraries folder (usually My Documents\Arduino\libraries)
  • Restart the Arduino IDE

github-full