Armand Coetzer / L298HBridge
Embed: (wiki syntax)

« Back to documentation index

L298HBridge Class Reference

L298HBridge Class Reference

Class library for a L298 H-Bridge. More...

#include <L298HBridge.h>

Public Member Functions

 L298HBridge (PinName ENpin, PinName FWDpin, PinName REVpin)
 Create a L298HBridge object connected to the specified pins.
void Fwd ()
 Setting the DC motor to spin in the forward direction.
void Rev ()
 Setting the DC motor to spin in the Revers direction.
void Stop ()
 Stopping the motor.
void SetSpeed (float PWMPercentage)
 Set the speed of the motor.

Detailed Description

Class library for a L298 H-Bridge.

Example:

 #include "mbed.h"
 #include "L298HBridge.h"

 L298HBridge dcmotor(PA_5, PA_6, PA_10); //Create a L298HBridge object with enable pin on PA5, Fwd pin or PA6 and Rev pin on PA10

 int main() 
 {
    while(1)
    {
          dcmotor.Fwd();               //setting the motor to spin forward
          dcmotor.SetSpeed(0.5);       //setting the speed the motor will spin
    }    
 }

Definition at line 50 of file L298HBridge.h.


Constructor & Destructor Documentation

L298HBridge ( PinName  ENpin,
PinName  FWDpin,
PinName  REVpin 
)

Create a L298HBridge object connected to the specified pins.

Once created, The pins still need to be set to a direction and also the speed via PWM.

Parameters:
ENpinPwmOut compatible pin used to set the speed of the motor.
FWDpinUsed to spin the motor in the forward direction.
REVDpinUsed to spin the motor in the Reverse direction.

Definition at line 4 of file L298HBridge.cpp.


Member Function Documentation

void Fwd (  )

Setting the DC motor to spin in the forward direction.

Parameters:
None

Definition at line 11 of file L298HBridge.cpp.

void Rev (  )

Setting the DC motor to spin in the Revers direction.

Parameters:
None

Definition at line 17 of file L298HBridge.cpp.

void SetSpeed ( float  PWMPercentage )

Set the speed of the motor.

Parameters:
PWMPercentage,variableto set te speed of the motor (any value from 0.1 - 1).
Returns:
None

Definition at line 31 of file L298HBridge.cpp.

void Stop (  )

Stopping the motor.

Parameters:
None

Definition at line 23 of file L298HBridge.cpp.