software to control a DC motor, preferably interfacing with a motor driver.

Dependents:   Car_Simulator

Embed: (wiki syntax)

« Back to documentation index

DCMotor Class Reference

DCMotor Class Reference

DC motor control class with PWM control. More...

#include <DCMotor.h>

Public Member Functions

 DCMotor (PinName PWMPin, PinName PinA, PinName PinB)
 create a DCMotor object connected to the pins with speed control
void driveIt (float)
 drive Motor input range (-100 to 100).

Detailed Description

DC motor control class with PWM control.

Example:

 #include "mbed.h"
 #include "DCMotor.h"
 
 DCMotor a(p21,p22,p23);
 DCMotor b(p24,p25,p26);
 int main() {
     a.driveIt(50);
     b.driveIt(50);
 }

Definition at line 24 of file DCMotor.h.


Constructor & Destructor Documentation

DCMotor ( PinName  PWMPin,
PinName  PinA,
PinName  PinB 
)

create a DCMotor object connected to the pins with speed control

Parameters:
PWMPinPWM pin to control speed of motor
PinADigital output pin to connect to motor
PinBDigital output pin to connect to motor

Definition at line 4 of file DCMotor.cpp.


Member Function Documentation

void driveIt ( float  perCent )

drive Motor input range (-100 to 100).

Parameters:
perCentPWM pin to control speed of motor

Definition at line 14 of file DCMotor.cpp.