31 lines
781 B
C
31 lines
781 B
C
|
#ifndef Motor_h
|
|||
|
#define Motor_h
|
|||
|
|
|||
|
#include <AccelStepper.h>
|
|||
|
|
|||
|
class Motor {
|
|||
|
private:
|
|||
|
int dirPin; //馬達 7
|
|||
|
int stepPin; //馬達 6
|
|||
|
int HIGHLimit; //正極限(距離正) 正轉
|
|||
|
int LOWLimit; //負極限(距離負) 反轉
|
|||
|
float stepDistance; //0.000625 步長
|
|||
|
float speed; //1600 馬達的速度,1600步/秒
|
|||
|
AccelStepper stepper;
|
|||
|
float _currentPosition;
|
|||
|
float _targetPosition;
|
|||
|
|
|||
|
|
|||
|
public:
|
|||
|
Motor(int dirPin, int stepPin, int HIGHLimit, int LOWLimit, float stepDistance, float speed);
|
|||
|
void move(float distance);
|
|||
|
void stop();
|
|||
|
float getCurrentPosition();
|
|||
|
void resetPosition();
|
|||
|
void moveDis(float distance);
|
|||
|
void moveToHighLim();
|
|||
|
void motorMove(float distance);
|
|||
|
void changeSpeed(int speed);
|
|||
|
};
|
|||
|
#endif
|