-
Notifications
You must be signed in to change notification settings - Fork 0
Motors_Lib
Haiqiang Xu edited this page Jun 15, 2018
·
2 revisions
Controls up to 4 motors split into 2 axes through the driver L298N. For each axis of two tyres, this driver needs 3 output pins (total of 6 pins to control the 2 axes):
- one pin controls one tyre's direction and another pin controls the other tyre's of the axis direction. They should be attached to digital pins as they accept values 0 and 1 that represents one direction or the opposite. Both pins set to 0 stops both motors and both pins set to 1 is not allowed.
- the last pin controls the movement/speed of these tyres. This speed should be attached to analog pin with a range of [0, 255] that will provide [0V, maxV] depending of the battery that powers up the motor.
- Since issue #3, added ETurnMode that permits change direction mode: ETurnMode::One like a tank with only one axis in movement, or ETurnMode::Both with one axis faster than the other axis, which is right now the default mode
- SetSpeedMode(ESpeedMode speedMode): sets the max. speed to one of the enumeration values: {None, Slow, Normal, Fast, Turbo} which corresponds to max. values {0, 55, 110, 165, 220}. Turbo value doesn't reach maximum of value 255 as a security measure.
- ProcessMotors(String sCommand): sets the motors movement to one of the EMovements enumeration values: { Stop, Up, Down, LeftUp, LeftDown, RightUp, RightDown } depending to the string received. This method is better for motors controlled by bluetooth module and string commands is set to move the motors.
- ProcessMotors(const byte byteX, const byte byteY): sets the motors movement to one of the EMovements enumeration values: { Stop, Up, Down, LeftUp, LeftDown, RightUp, RightDown } depending to parameter coordinates values. This method is better for motors controlled by a joystick as its analog movement will correspond to the motors movement.
Please, feel free to add any question or bug here
External Libraries