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.
Dependencies: LSM9DS1 RangeFinder FastPWM
Dependents: PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board ... more
Servo.h@16:69911e81dfd4, 2022-03-21 (annotated)
- Committer:
- pmic
- Date:
- Mon Mar 21 13:47:46 2022 +0000
- Revision:
- 16:69911e81dfd4
- Parent:
- 10:fe74e8909d3f
- Child:
- 18:21c0a669d6ef
Changed Servo class for normilized input.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pmic | 0:86129f1b4a93 | 1 | /* mbed Servo Library without using PWM pins |
| pmic | 0:86129f1b4a93 | 2 | * Copyright (c) 2010 Jasper Denkers |
| pmic | 0:86129f1b4a93 | 3 | * |
| pmic | 0:86129f1b4a93 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| pmic | 0:86129f1b4a93 | 5 | * of this software and associated documentation files (the "Software"), to deal |
| pmic | 0:86129f1b4a93 | 6 | * in the Software without restriction, including without limitation the rights |
| pmic | 0:86129f1b4a93 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| pmic | 0:86129f1b4a93 | 8 | * copies of the Software, and to permit persons to whom the Software is |
| pmic | 0:86129f1b4a93 | 9 | * furnished to do so, subject to the following conditions: |
| pmic | 0:86129f1b4a93 | 10 | * |
| pmic | 0:86129f1b4a93 | 11 | * The above copyright notice and this permission notice shall be included in |
| pmic | 0:86129f1b4a93 | 12 | * all copies or substantial portions of the Software. |
| pmic | 0:86129f1b4a93 | 13 | * |
| pmic | 0:86129f1b4a93 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| pmic | 0:86129f1b4a93 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| pmic | 0:86129f1b4a93 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| pmic | 0:86129f1b4a93 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| pmic | 0:86129f1b4a93 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| pmic | 0:86129f1b4a93 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| pmic | 0:86129f1b4a93 | 20 | * THE SOFTWARE. |
| pmic | 0:86129f1b4a93 | 21 | */ |
| pmic | 0:86129f1b4a93 | 22 | |
| pmic | 0:86129f1b4a93 | 23 | #ifndef MBED_SERVO_H |
| pmic | 0:86129f1b4a93 | 24 | #define MBED_SERVO_H |
| pmic | 0:86129f1b4a93 | 25 | |
| pmic | 10:fe74e8909d3f | 26 | #include "mbed.h" |
| pmic | 10:fe74e8909d3f | 27 | |
| pmic | 4:9c003c402033 | 28 | class Servo |
| pmic | 4:9c003c402033 | 29 | { |
| pmic | 0:86129f1b4a93 | 30 | |
| pmic | 0:86129f1b4a93 | 31 | public: |
| pmic | 16:69911e81dfd4 | 32 | |
| pmic | 0:86129f1b4a93 | 33 | Servo(PinName Pin); |
| pmic | 16:69911e81dfd4 | 34 | void SetPosition(float _Input); |
| pmic | 16:69911e81dfd4 | 35 | void Enable(float _StartInput, int _Period); |
| pmic | 0:86129f1b4a93 | 36 | void Disable(); |
| pmic | 0:86129f1b4a93 | 37 | |
| pmic | 0:86129f1b4a93 | 38 | private: |
| pmic | 0:86129f1b4a93 | 39 | void StartPulse(); |
| pmic | 0:86129f1b4a93 | 40 | void EndPulse(); |
| pmic | 0:86129f1b4a93 | 41 | |
| pmic | 16:69911e81dfd4 | 42 | int Position, Period; |
| pmic | 0:86129f1b4a93 | 43 | DigitalOut ServoPin; |
| pmic | 0:86129f1b4a93 | 44 | Ticker Pulse; |
| pmic | 0:86129f1b4a93 | 45 | Timeout PulseStop; |
| pmic | 0:86129f1b4a93 | 46 | }; |
| pmic | 0:86129f1b4a93 | 47 | |
| pmic | 0:86129f1b4a93 | 48 | #endif |
