for a stepper with a limit switch see sample on the following url https://os.mbed.com/users/Dennis_Yu/code/stepper_sample/

Fork of stepper by Xiaoyuan Yu

stepper.h

Committer:
Dennis_Yu
Date:
2018-07-27
Revision:
8:94661b4fa780
Parent:
7:7e9b9f386945

File content as of revision 8:94661b4fa780:

#include <mbed.h>

#ifndef STEPPER_H
#define STEPPER_H

class stepperMotor
{
  private:
    DigitalOut step;
    DigitalOut dir;
    DigitalOut en;
    double movedAngle;
    DigitalIn limitSwitch;
    Ticker stepper;
    void moveStepper();
    void setDir(bool direction);
//    void enable(int inputRemain);
//    void enable();
    void disable();
    void pause();
//  public:
//    void moveAngle(double angle);
  public:
    int remain;
//    stepperMotor();
    stepperMotor(PinName stepPin, PinName dirPin, PinName enPin, PinName limitSwitchPin, float period);
//    void setDir(bool direction);
    void enable(int inputRemain);
    void enable();
//    void disable();
//    void pause();
    void init();
    void moveAngle(double angle);
};

#endif