Kallums Fork
Fork of SteeringServo by
SteeringServo Class Reference
NAME: SteeringServo AUTHOR: J.BATCHELAR. More...
#include <SteeringServo.h>
Public Member Functions | |
| SteeringServo (PinName pin, int centrePW, int minPW, int maxPW) | |
| Create a Clamp Servo Object. | |
| void | goToAngle (int pulseWidth) |
| Check if the Clamp is Open. | |
| void | goStraight (void) |
| Goto the centre position. | |
| int | getPulseWidth (void) |
| Get the currentPulseWidth. | |
Detailed Description
NAME: SteeringServo AUTHOR: J.BATCHELAR.
LICENSE
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.
DESCRIPTION
Used with Tower Pro 9g Servo Motors (http://www.micropik.com/PDF/SG90Servo.pdf) to create a steering mechanism.
Example:
// -- Code to move steering wheel between extreme limits #include "mbed.h" #include "SteeringServo.h" DigitalIn bttn(PC_13); DigitalOut led(LED1); Serial pc(USBTX, USBRX); SteeringServo steerMech(PA_10, 1650, 1000, 2300); int main() { led = 1; pc.printf("\nServo Example\n"); while(1){ steerMech.goStraight(); //-- Don't call constantly(as you are writing into register need to allow time for value to set)! //-- Wait for button to be pressed while(bttn){}; steerMech.goToAngle(1000); //-- Go Left wait(5); steerMech.goToAngle(2300); //-- Go Left wait(5); } }
Definition at line 63 of file SteeringServo.h.
Constructor & Destructor Documentation
| SteeringServo | ( | PinName | pin, |
| int | centrePW, | ||
| int | minPW, | ||
| int | maxPW | ||
| ) |
Create a Clamp Servo Object.
- Parameters:
-
pin The PWM Pin that the Servo Is Connected To centrePW (us) - Pulse Width to move to drive straight minPW (us) - Minimum pulse width that servo can move to (due to mechanical constraints) maxPW (us) - Maximum pulse width that servo can move to (due to mechanical constraints)
Definition at line 4 of file SteeringServo.cpp.
Member Function Documentation
| int getPulseWidth | ( | void | ) |
Get the currentPulseWidth.
Definition at line 36 of file SteeringServo.cpp.
| void goStraight | ( | void | ) |
| void goToAngle | ( | int | pulseWidth ) |
Check if the Clamp is Open.
- Parameters:
-
pulseWidth (us) - Pulse Width to move rotate to (is internally constrained by limits)
Definition at line 14 of file SteeringServo.cpp.
Generated on Wed Jul 13 2022 17:25:00 by
1.7.2
