Class library for a L298 H-Bridge
Dependents: inverted_pendulum_system
Fork of L298HBridge by
Diff: L298HBridge.h
- Revision:
- 1:6d242bb216d6
- Parent:
- 0:39561fe6e4ff
- Child:
- 2:1c000b6cf863
--- a/L298HBridge.h Thu Jan 19 11:33:01 2017 +0000 +++ b/L298HBridge.h Thu Jan 19 12:34:48 2017 +0000 @@ -27,53 +27,42 @@ #include "mbed.h" -/** Class library for a HC-SR04 Distance Sensor based on PwmOut (Trig) and InterruptIn (Echo). +/** Class library for a L298 H-Bridge. * * Example: * @code - * #include "mbed.h" - * #include "HCSR04.h" - * - * HCSR04 distance(PB_8, PA_1); - * - * int main() { - * while(1){ - * SWO.printf("Distance = %d (us) %f (cm)\n", distance.read_us(), distance.read_cm()); - * } - * } + * * @endcode */ class L298HBridge { public: - /** Create a HCSR04 object connected to the specified pins. Once created, the PWM signal - * on the Trig pin will start immediately and measurements will start in the background. - * @param ENPin PwmOut compatible pin used to connect to HC-SR04's Trig pin - * @param EchoPin InterruptIn compatible pin used to connect to HC-SR04's Echo pin + /** Create a L298HBridge object connected to the specified pins. + * Once created, the motor speed will be set to 0 (PWM signal will be 0%) and + * the motor will be in the "stop" direction (neither forward or reverse). + * @param ENPin PwmOut compatible pin used to connect to L298's En pin associated with enabling the H-Bridge. + * @param FWDPin GPIO pin used to connect to L298's In pin associated with forward direction. + * @param REVPin GPIO pin used to connect to L298's In pin associated with reverse direction. */ L298HBridge(PinName ENPin, PinName FWDPin, PinName REVPin); - /** Create a HCSR04 object connected to the specified pins. Once created, the PWM signal - * on the Trig pin will start immediately and measurements will start in the background. + /** Switch the H-Bridge to run the motor in the forward direction. * @param None */ void Fwd(); - /** Create a HCSR04 object connected to the specified pins. Once created, the PWM signal - * on the Trig pin will start immediately and measurements will start in the background. + /** Switch the H-Bridge to run the motor in the reverse direction. * @param None */ void Rev(); - /** Create a HCSR04 object connected to the specified pins. Once created, the PWM signal - * on the Trig pin will start immediately and measurements will start in the background. + /** Switch the H-Bridge off. The H-Bridge is not set to forward or reverse. * @param None */ void Stop(); - /** Create a HCSR04 object connected to the specified pins. Once created, the PWM signal - * on the Trig pin will start immediately and measurements will start in the background. - * @param None + /** Change the motor's speed by adjusting the PWM signal. + * @param int DutyPercent */ void Speed(int DutyPercent);