Arduino Forum

Development => Other Software Development => Topic started by: Kraftzwerk on Sep 26, 2017, 11:11 pm

Title: Another stepper lib for 28byj-48 with awesome actions and fine grained control
Post by: Kraftzwerk on Sep 26, 2017, 11:11 pm
Hi guys,

i wrote this small library specially for the 28byj-48, StepperControl (https://github.com/Erhan-MADE/StepperControl), it has some nice features like different drive modes, speed control and direction settings.

It was designed to behave like the awesome Stepper library that is shipped with the arduino but with some extensions.

As i'm pretty new to Arduino some constructive critic and feature requests would be very appreciated.
Title: Re: Another stepper lib for 28byj-48
Post by: Kraftzwerk on Sep 27, 2017, 12:43 am
A new feature was added: Actions!

Now you can specify a sequence of movements and just add them to an array.
The actions also give you the possibility to have Callbacks that will get triggered when the movement the action is finished.

  #include <StepperControl.h>
   
    StepperControl control(StepperControl::DefaultStepCount, 8,9,10,11);
 
    void Callback()
    {
      Serial.println("i am a callback");
    }
    void Callback2()
    {
      Serial.println("i, too am a callback");
    }
   
    void setup()
    {
      Serial.begin(9600);
      control.SetDirection(StepperControl::Backward);
      control.SetRotationSpeed(2);
      control.SetStepType(StepperControl::FullStep);

      StepperControl::StepperAction action;
      action.Direction = StepperControl::Forward;
      action.Type = StepperControl::WaveDrive;
      action.Rpm = 1.5;
      action.StartDelay = 1000;
      action.Steps = 1400;
      action.EndDelay = 500;
      action.DidEndCallback = &Callback;

      control.AddStepperAction(action);

 
      StepperControl::StepperAction action2;
      action2.Direction = StepperControl::Backward;
      action2.Type = StepperControl::FullStep;
      action2.Rpm = 2.5;
      action2.StartDelay = 2000;
      action2.Steps = 1800;
      action2.EndDelay = 560;
      action2.DidEndCallback = &Callback2;

      control.AddStepperAction(action2);
    }

    void loop()
    {
      control.StartAction();
      delay(1000);
    }