Smartcar Shield
|
#include <ServoMotor.hpp>
Public Member Functions | |
ServoMotor (uint8_t controlPin, int minPulseLength=smartcarlib::constants::servomotor::kDefaultMinPulseLength, int idlePulseLength=smartcarlib::constants::servomotor::kDefaultIdlePulseLength, int maxPulseLength=smartcarlib::constants::servomotor::kDefaultMaxPulseLength) | |
Constructs a servo motor. 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 motor that is controlled via the length of pulses that are sent to it through a single signal line. It can be either a traditional servo motor that controls a shaft (e.g. for steering) or an Electronic Speed Controller (ESC) that interpets speed in the same manner and controls a (typically brushless) motor.
Definition at line 29 of file ServoMotor.hpp.
ServoMotor::ServoMotor | ( | uint8_t | controlPin, |
int | minPulseLength = smartcarlib::constants::servomotor::kDefaultMinPulseLength , |
||
int | idlePulseLength = smartcarlib::constants::servomotor::kDefaultIdlePulseLength , |
||
int | maxPulseLength = smartcarlib::constants::servomotor::kDefaultMaxPulseLength |
||
) |
Constructs a servo motor.
controlPin | The pin controlling the speed of the motor |
minPulseLength | The motor's minimum pulse length in microseconds |
idlePulseLength | The pulse length that the motor is idle in microseconds |
maxPulseLength | The motor's maximum pulse length in microseconds |
Example:
Definition at line 7 of file ServoMotor.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 19 of file ServoMotor.cpp.