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@0:e6f25efb6af9, 2015-03-23 (annotated)
- Committer:
- marcel1691
- Date:
- Mon Mar 23 17:10:05 2015 +0000
- Revision:
- 0:e6f25efb6af9
- Child:
- 1:32f0eb92121b
Servo Beispiel
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| marcel1691 | 0:e6f25efb6af9 | 1 | /** Servo |
| marcel1691 | 0:e6f25efb6af9 | 2 | */ |
| marcel1691 | 0:e6f25efb6af9 | 3 | #include "mbed.h" |
| marcel1691 | 0:e6f25efb6af9 | 4 | #include "Servo.h" |
| marcel1691 | 0:e6f25efb6af9 | 5 | |
| marcel1691 | 0:e6f25efb6af9 | 6 | Servo servo(A5); |
| marcel1691 | 0:e6f25efb6af9 | 7 | |
| marcel1691 | 0:e6f25efb6af9 | 8 | int main() |
| marcel1691 | 0:e6f25efb6af9 | 9 | { |
| marcel1691 | 0:e6f25efb6af9 | 10 | while ( 1 ) |
| marcel1691 | 0:e6f25efb6af9 | 11 | { |
| marcel1691 | 0:e6f25efb6af9 | 12 | // Servo langsam bewegen (immer in der Mitte Anfangen mit Tests, sonst besteht die Gefahr von Schäden) |
| marcel1691 | 0:e6f25efb6af9 | 13 | for ( float p = 0.4f; p < 0.6f; p += 0.0001f ) |
| marcel1691 | 0:e6f25efb6af9 | 14 | { |
| marcel1691 | 0:e6f25efb6af9 | 15 | servo = p; |
| marcel1691 | 0:e6f25efb6af9 | 16 | wait(0.001); |
| marcel1691 | 0:e6f25efb6af9 | 17 | } |
| marcel1691 | 0:e6f25efb6af9 | 18 | wait( 1.0 ); |
| marcel1691 | 0:e6f25efb6af9 | 19 | // und die andere Seite |
| marcel1691 | 0:e6f25efb6af9 | 20 | for ( float p = 0.6f; p >= 0.4f; p -= 0.0001f ) |
| marcel1691 | 0:e6f25efb6af9 | 21 | { |
| marcel1691 | 0:e6f25efb6af9 | 22 | servo = p; |
| marcel1691 | 0:e6f25efb6af9 | 23 | wait(0.001); |
| marcel1691 | 0:e6f25efb6af9 | 24 | } |
| marcel1691 | 0:e6f25efb6af9 | 25 | wait( 1.0 ); |
| marcel1691 | 0:e6f25efb6af9 | 26 | } |
| marcel1691 | 0:e6f25efb6af9 | 27 | } |
| marcel1691 | 0:e6f25efb6af9 | 28 |