screwdriver/Motor/Program/1125MotorTest/Motor.h
2025-02-06 16:10:58 +08:00

31 lines
781 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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