Class library for a L298 H-Bridge
Dependents: inverted_pendulum_system
Fork of L298HBridge by
L298HBridge.h
- Committer:
- RiaanEhlers
- Date:
- 2017-01-19
- Revision:
- 0:39561fe6e4ff
- Child:
- 1:6d242bb216d6
File content as of revision 0:39561fe6e4ff:
/* L298HBridge Library v1.0 * Copyright (c) 2017 Riaan Ehlers * riaan.ehlers@nmmu.ac.za * * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef L298HBridge_H #define L298HBridge_H #include "mbed.h" /** Class library for a HC-SR04 Distance Sensor based on PwmOut (Trig) and InterruptIn (Echo). * * 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 */ 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. * @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. * @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. * @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 */ void Speed(int DutyPercent); private: PwmOut _ENPin; DigitalOut _FWDPin, _REVPin; }; #endif