Create a motor object, to control a motor using L293DNE and FDRM-KL46z.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Motor Class Reference

Motor Class Reference

Motor class, create motor object to control speed and direction. More...

#include <Motor.h>

Public Member Functions

 Motor (PinName Positive, PinName Negative)
 Create a motor object.
void Direction (int move)
 control the direction of the movement
void Stop ()
 Stop the motor.
void Speed (int motor_speed)
 control the speed of the motor object

Detailed Description

Motor class, create motor object to control speed and direction.

Example:

 #include "mbed.h"
 #include "Motor.h"
 Motor my_motor(P12,P13P,p11);
 
 int main() {
 my_motor.Direction(LEFT);
 wait(0.1);
 }

Definition at line 21 of file Motor.h.


Constructor & Destructor Documentation

Motor ( PinName  Positive,
PinName  Negative 
)

Create a motor object.

Parameters:
Postiveinput of A1 on L293DNE
Negativeinput of A2 on L293DNE
SpeedPWM output -> EN1,2 on L293DNE

Definition at line 4 of file Motor.cpp.


Member Function Documentation

void Direction ( int  move )

control the direction of the movement

Parameters:
moveis LEFT or RIGHT defined as 1 and 2 in Motor.h

Definition at line 14 of file Motor.cpp.

void Speed ( int  motor_speed )

control the speed of the motor object

Parameters:
motor_speedfrom 0 to 100. 0 is the slowest and 100 is max speed.

Definition at line 33 of file Motor.cpp.

void Stop (  )

Stop the motor.

Definition at line 28 of file Motor.cpp.