offer some APIs to control the movement of motor. Suitable with Seeed motor shield

Dependents:   Seeed_Motor_Shield_HelloWorld Seeed_Motor_Shield

Embed: (wiki syntax)

« Back to documentation index

MotorDriver Class Reference

MotorDriver Class Reference

Motor Driver class. More...

#include <MotorDriver.h>

Public Member Functions

 MotorDriver (PinName int1, PinName int2, PinName int3, PinName int4, PinName speedA, PinName speedB)
 Create Motor Driver instance.
void init ()
 set motor to initialized state
void configure (uint8_t position, uint8_t motorID)
 config position of motor
void setSpeed (uint8_t speed, uint8_t motorID)
 set speed of motor
void setDirection (uint8_t direction, uint8_t motorID)
 set direction of motor,
void rotate (uint8_t direction, uint8_t motor_position)
 rotate motor
void rotateWithID (uint8_t direction, uint8_t motorID)
 rotate motorA or motorB
void goForward ()
 make motor go forward
void goBackward ()
 make motor go backward
void goLeft ()
 make motor go left
void goRight ()
 make motor go right
void stop ()
 make motor stop
void stop (uint8_t motorID)
 make motorA or motorB stop

Data Fields

MotorStruct motorA
 motor A
MotorStruct motorB
 motor B

Detailed Description

Motor Driver class.

offer API to control the movement of motor

Definition at line 53 of file MotorDriver.h.


Constructor & Destructor Documentation

MotorDriver ( PinName  int1,
PinName  int2,
PinName  int3,
PinName  int4,
PinName  speedA,
PinName  speedB 
)

Create Motor Driver instance.

Parameters:
int1pin 1 of motor movement control
int2pin 2 of motor movement control
int3pin 3 of motor movement control
int4pin 4 of motor movement control
speedAspeed control of motorA
speedBspeed control of motorB

Definition at line 66 of file MotorDriver.h.


Member Function Documentation

void configure ( uint8_t  position,
uint8_t  motorID 
)

config position of motor

Parameters:
positionthe position set to motor,MOTOR_POSITION_LEFT or MOTOR_POSITION_RIGHT will be allowed
motorIDthe ID define which motor will be set, you can choose MOTORA or MOTORB

Definition at line 37 of file MotorDriver.cpp.

void goBackward (  )

make motor go backward

Definition at line 82 of file MotorDriver.cpp.

void goForward (  )

make motor go forward

Definition at line 77 of file MotorDriver.cpp.

void goLeft (  )

make motor go left

Definition at line 87 of file MotorDriver.cpp.

void goRight (  )

make motor go right

Definition at line 92 of file MotorDriver.cpp.

void init (  )

set motor to initialized state

Definition at line 25 of file MotorDriver.cpp.

void rotate ( uint8_t  direction,
uint8_t  motor_position 
)

rotate motor

Parameters:
directionthe direction set to motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed
motor_positionthe position set to motor,MOTOR_POSITION_LEFT or MOTOR_POSITION_RIGHT will be allowed

Definition at line 54 of file MotorDriver.cpp.

void rotateWithID ( uint8_t  direction,
uint8_t  motorID 
)

rotate motorA or motorB

Parameters:
directionthe direction set to motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed
motorIDthe ID define which motor will be set, you can choose MOTORA or MOTORB

Definition at line 64 of file MotorDriver.cpp.

void setDirection ( uint8_t  direction,
uint8_t  motorID 
)

set direction of motor,

Parameters:
directionthe direction of motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed
motorIDthe ID define which motor will be set, you can choose MOTORA or MOTORB

Definition at line 48 of file MotorDriver.cpp.

void setSpeed ( uint8_t  speed,
uint8_t  motorID 
)

set speed of motor

Parameters:
speedspeed value set to motor, [0,100] will be allowed
motorIDthe ID define which motor will be set, you can choose MOTORA or MOTORB

Definition at line 43 of file MotorDriver.cpp.

void stop (  )

make motor stop

Definition at line 98 of file MotorDriver.cpp.

void stop ( uint8_t  motorID )

make motorA or motorB stop

Parameters:
motorIDthe ID define which motor will be set, you can choose MOTORA or MOTORB

Definition at line 104 of file MotorDriver.cpp.


Field Documentation

MotorStruct motorA

motor A

Definition at line 134 of file MotorDriver.h.

MotorStruct motorB

motor B

Definition at line 138 of file MotorDriver.h.