20 int encoder_pin_a,
int encoder_pin_b) :
21 _encoder(encoder_pin_a, encoder_pin_b) {
54 _setupDCMotor(pin_a, pin_b);
71 }
else if (speed < 0) {
78 return _runDCMotor(speed);
80 return _runBLDCMotor(speed);
82 return _runServoMotor(speed);
95 long int motor_position = _encoder.read();
97 return motor_position;
102 void Motor::_setupDCMotor(
int pin_a,
int pin_b) {
114 void Motor::_setupBLDCMotor(
void) {
121 for (
int ppm = 45; ppm < 90; ppm++) {
125 for (
int ppm = 90; ppm > 0; ppm--) {
129 for (
int ppm = 0; ppm < 45; ppm++) {
139 void Motor::_runDCMotor(
int speed) {
162 void Motor::_runBLDCMotor(
int speed) {
164 _servo.writeMicroseconds(speed);
168 void Motor::_runServoMotor(
int position) {
183 String Motor::_getMotorTypeName(
void) {
191 return "Brushless DC";
void displayDebug(String)
int void displayInfo(String)
void displayInfo(String)
int displayError(int)
long getPosition(void)
Returns the position of the motor.
int setupMotor(int, int, int pin_a=0, int pin_b=0)
Sets up the pins of the motor class.
Motor(int, int, int pin_a=0, int pin_b=0)
Default constructor.
void run(int)
Run the motor at the desired speed and direction or position.
Header file for Motor class
#define ENCODER_SETUP_ERROR
Header file for error codes