MeEncoderMotor(uint8_t addr,uint8_t slot);
Description:
Constructor of Encoder Motor.
Parameters:
uint8_t addr: I2C address of driver module
uint8_t slot: the motor number, can be SLOT1 or SLOT2.
Example:
MeEncoderMotor motor1(0x09, SLOT1); MeEncoderMotor motor2(0x09, SLOT2);
void begin();
Description:
Initialize the motor and start it.
Example:
motor1.begin();
boolean Reset();
Description:
Reset the position to 0 and reinitialize the motor.
Example:
motor1.Reset();
boolean Move(float angle, float speed);
Description:
Run the motor by a angle, with a specified speed.
Parameters:
float angle: The relative angle (in degrees). It can be positive or negative.
float speed: The running speed (in RPM).
Example:
// Run 360° with the speed of 100 RPM motor1.Move(360, 100);
boolean MoveTo(float angle, float speed);
Description:
Move to the absolute angle, with a specified speed.
Parameters:
float angle: The absolute angle (in degrees). It can be positive or negative.
fleat speed: The running speed (in RPM).
Example:
// Run to the initial position, with the speed of 150 RPM motor1.Movo(0, 150);
boolean RunTurns(float turns, float speed);
Description:
It is like Move(float angle, float speed), 1 turn is equal to 360 degrees.
Parameters:
float turns: The relative turns. It can be positive or negative.
float speed: The running speed (in RPM).
Example:
//Run five turns motor1.RunTurns(5, 100);
boolean RunSpeed(float speed);
Description:
Run in a specified speed and keep it.
Parameters:
float speed: The running speed (in RPM).
Example:
// Run with the speed of 42 RPM motor1.RunSpeed(42);
boolean RunSpeedAndTime(float speed, float time);
Description:
Run in a specified speed and time.
Parameters:
float speed: The running speed (in RPM).
float time: The running time (in milli-seconds).
Example:
// Run for 3 seconds with the speed of 20 RPM motor1.RunSpeedAndTime(20, 3000);
float GetCurrentSpeed();
Decription:
Get the current speed.
Return:
The current speed (in RPM).
Example:
float currentSpeed = motor1.GetCurrentSpeed();
float GetCurrentPosition();
Description:
Get the current position.
Return:
The current position (in degrees).
Example:
float currentPos = motor1.GetCurrentPosition();