Smartcar Shield
|
#include <BrushedMotor.hpp>
Public Member Functions | |
BrushedMotor (Runtime &runtime, uint8_t forwardPin, uint8_t backwardPin, uint8_t enablePin) | |
Constructs a brushed DC motor instance. More... | |
BrushedMotor (Runtime &runtime, BrushedMotorPins pins) | |
Constructs a brushed DC motor instance. More... | |
void | setSpeed (int speed) override |
Sets the motor speed and direction as the percentage of the maximum possible speed, where the sign of the argument represents the direction. More... | |
Public Member Functions inherited from Motor | |
virtual | ~Motor ()=default |
A brushed motor is controlled via two wires where the flow of current determines the direction of rotation and the duty cycle the speed.
For their control, we will assume the existince of a half-bridge such as the L293D chip where three signals are needed, two for determining the direction and another for determining the speed.
Definition at line 41 of file BrushedMotor.hpp.
BrushedMotor::BrushedMotor | ( | Runtime & | runtime, |
uint8_t | forwardPin, | ||
uint8_t | backwardPin, | ||
uint8_t | enablePin | ||
) |
Constructs a brushed DC motor instance.
runtime | The runtime environment you want to run the class for |
forwardPin | The direction pin that when set to HIGH makes the motor spin forward |
backwardPin | The direction pin that when set to HIGH makes the motor spin forward |
enablePin | The pin that controls the motor's speed |
Example:
Definition at line 13 of file BrushedMotor.cpp.
BrushedMotor::BrushedMotor | ( | Runtime & | runtime, |
BrushedMotorPins | pins | ||
) |
Constructs a brushed DC motor instance.
runtime | The runtime environment you want to run the class for |
pins | The BrushedMotorPins object with the pins of the motor |
Example:
Definition at line 27 of file BrushedMotor.cpp.
|
overridevirtual |
Sets the motor speed and direction as the percentage of the maximum possible speed, where the sign of the argument represents the direction.
speed | The speed and direction within the range of [-100, 100]. -100 means that the motor is spinning at full speed towards the direction we have defined as backward. 100 interpreted as full speed forward. 0 means that the motor is at its idle/neutral state. |
Example:
Implements Motor.
Definition at line 32 of file BrushedMotor.cpp.