Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select). ES200 fork with line 31 of motor.cpp modified.

Dependents:   Fa2018-es200-1121-3321-thread-example Fa2018-es200-1121-3321-thread-example-peanut Fa2018-es200-1121-3321-thread-example-herndon Fa2018-es200-1121-3321-thread-example-rockem

Fork of Motor by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Motor Class Reference

Motor Class Reference

Interface to control a standard DC motor. More...

#include <Motor.h>

Public Member Functions

 Motor (PinName pwm, PinName fwd, PinName rev)
 Create a motor control interface.
void speed (float speed)
 Set the speed of the motor.

Detailed Description

Interface to control a standard DC motor.

with an H-bridge using a PwmOut and 2 DigitalOuts

Definition at line 32 of file Motor.h.


Constructor & Destructor Documentation

Motor ( PinName  pwm,
PinName  fwd,
PinName  rev 
)

Create a motor control interface.

Parameters:
pwmA PwmOut pin, driving the H-bridge enable line to control the speed
fwdA DigitalOut, set high when the motor should go forward
revA DigitalOut, set high when the motor should go backwards

Definition at line 27 of file Motor.cpp.


Member Function Documentation

void speed ( float  speed )

Set the speed of the motor.

Parameters:
speedThe speed of the motor as a normalised value between -1.0 and 1.0

Definition at line 39 of file Motor.cpp.