Class library for a L298 H-Bridge
Dependents: inverted_pendulum_system
Fork of L298HBridge by
L298HBridge.cpp
- Committer:
- RiaanEhlers
- Date:
- 2017-01-20
- Revision:
- 2:1c000b6cf863
- Parent:
- 1:6d242bb216d6
- Child:
- 3:dabd8b6b2bff
File content as of revision 2:1c000b6cf863:
#include "L298HBridge.h" #include "mbed.h" L298HBridge::L298HBridge(PinName ENPin, PinName FWDPin, PinName REVPin) : _ENPin(ENPin), _FWDPin(FWDPin), _REVPin(REVPin) { _ENPin = 0; //PWM = 0% _FWDPin = 0; _REVPin = 0; _ENPin.period(0.020); //set PWM period to 20mS as default. } void L298HBridge::Fwd() { _FWDPin = 1; _REVPin = 0; } void L298HBridge::Rev() { _FWDPin = 0; _REVPin = 1; } void L298HBridge::Stop() { _FWDPin = 0; _REVPin = 0; } void L298HBridge::Speed(float DutyPercent) { _ENPin = DutyPercent /100; }