![]() |
Smart Car Controller
1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
|
#include <SC_DCMotor.h>
Public Member Functions | |
Class constructor and destructor. | |
SC_DCMotor_MX1508 (uint8_t pinIn1, uint8_t pinIn2) | |
~SC_DCMotor_MX1508 (void) | |
Methods for core object control. | |
bool | begin (void) |
void | run (runCmd_t cmd, uint8_t speed) |
void | setSpeed (uint16_t s) |
![]() | |
uint16_t | getSpeed () |
Additional Inherited Members | |
![]() | |
enum | runCmd_t { DIR_FWD , DIR_REV } |
![]() | |
runCmd_t | _mode |
The current mode for the motor. | |
uint16_t | _speed |
The current speed setting for the motor. | |
Core object for the derived SC_DCMotor_M1508 class
This motor controller uses 2 PWM capable pins for direction and PWM speed control.
SC_DCMotor_MX1508::SC_DCMotor_MX1508 | ( | uint8_t | pinIn1, |
uint8_t | pinIn2 | ||
) |
Class Constructor.
Instantiate a new instance of the class. This variant is for motor controllers that have a PWM input for speed control.
The main function for the core object is to reset the internal shared variables and timers to default values.
pinIn1 | The In1 pin number for command output to the controller. This is a PWM enabled pin. |
pinIn2 | The In2 pin number for command output to the controller. This is a PWM enabled pin. |
SC_DCMotor_MX1508::~SC_DCMotor_MX1508 | ( | void | ) |
Class Destructor.
Release any allocated memory and clean up anything else.
|
virtual |
Initialize the object.
Initialize the object data. Sets up the pins for output and puts the controlled in a stopped position.
Implements SC_DCMotor.
|
virtual |
Run/Stop the motor with speed.
This controls how the motor runs/stops. This sets the motor controller into the correct operating mode and then sets the speed to what is specified. The command specified is one of the runCmd_t values and the speed must be suitable for the setSpeed() method.
cmd | the run/stop mode. |
speed | the speed to run at. |
Implements SC_DCMotor.
|
virtual |
Set the speed for the motor
This controls the PWM setting for the motor. Note that the actual speed is dependent on the motor and it is unlikely that it will be a linear response across the range of valid values.
s | the speed setting [0..255]. |
Implements SC_DCMotor.