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.
main.cpp@3:600b3ff627a2, 2021-05-06 (annotated)
- Committer:
- CSTritt
- Date:
- Thu May 06 13:44:45 2021 +0000
- Revision:
- 3:600b3ff627a2
- Parent:
- 2:7709000dbbc4
Minor clean-up for smoother motion and quieter waiting.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| CSTritt | 2:7709000dbbc4 | 1 | /* |
| CSTritt | 2:7709000dbbc4 | 2 | Program MyServo_HelloWorld |
| CSTritt | 2:7709000dbbc4 | 3 | |
| CSTritt | 2:7709000dbbc4 | 4 | Hello World to sweep a servo through its full range. Based on example by |
| CSTritt | 2:7709000dbbc4 | 5 | Simon Ford. Minor modifications by Dr. C. S. Tritt. |
| CSTritt | 2:7709000dbbc4 | 6 | |
| CSTritt | 2:7709000dbbc4 | 7 | Last revised 5/5/21 ( v. 0.9) |
| CSTritt | 2:7709000dbbc4 | 8 | */ |
| simon | 1:40d2fd0b99e6 | 9 | |
| simon | 1:40d2fd0b99e6 | 10 | #include "mbed.h" |
| simon | 1:40d2fd0b99e6 | 11 | #include "Servo.h" |
| simon | 1:40d2fd0b99e6 | 12 | |
| CSTritt | 2:7709000dbbc4 | 13 | Servo myServo(D8); |
| simon | 1:40d2fd0b99e6 | 14 | |
| CSTritt | 2:7709000dbbc4 | 15 | int main() { |
| CSTritt | 2:7709000dbbc4 | 16 | for (int q=1; q < 6; q++) { |
| CSTritt | 3:600b3ff627a2 | 17 | for (double p = 0; p < 1.0; p += 0.05) { |
| CSTritt | 2:7709000dbbc4 | 18 | myServo = p; |
| CSTritt | 3:600b3ff627a2 | 19 | wait(0.1); |
| CSTritt | 2:7709000dbbc4 | 20 | } |
| CSTritt | 2:7709000dbbc4 | 21 | } |
| CSTritt | 2:7709000dbbc4 | 22 | while (true) { |
| CSTritt | 2:7709000dbbc4 | 23 | float hold = 0.5; |
| CSTritt | 2:7709000dbbc4 | 24 | myServo = hold; // Wait here forever. |
| CSTritt | 3:600b3ff627a2 | 25 | wait(1.0); |
| simon | 1:40d2fd0b99e6 | 26 | } |
| CSTritt | 2:7709000dbbc4 | 27 | } |