Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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:
-
ENpin PwmOut compatible pin used to set the speed of the motor. FWDpin Used to spin the motor in the forward direction. REVDpin Used 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,variable to set te speed of the motor (any value from 0.1 - 1).
- Returns:
- None
Definition at line 31 of file L298HBridge.cpp.
| void Stop | ( | ) |
Generated on Thu Jul 14 2022 15:57:24 by
1.7.2