![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Servo
Dependencies: mbed MODSERIAL Servo FastPWM
main.cpp@1:f6898c9b8c44, 2019-10-11 (annotated)
- Committer:
- AnkePost
- Date:
- Fri Oct 11 08:35:27 2019 +0000
- Revision:
- 1:f6898c9b8c44
- Parent:
- 0:60a8a60074a7
- Child:
- 2:381007cb7a70
Niet werkende servoaansturing met stapjes van 10 procent
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnkePost | 1:f6898c9b8c44 | 1 | // Hello World to sweep a servo through its full range |
AnkePost | 1:f6898c9b8c44 | 2 | |
AnkePost | 0:60a8a60074a7 | 3 | #include "mbed.h" |
AnkePost | 0:60a8a60074a7 | 4 | #include "Servo.h" |
AnkePost | 1:f6898c9b8c44 | 5 | #include <math.h> |
AnkePost | 0:60a8a60074a7 | 6 | |
AnkePost | 0:60a8a60074a7 | 7 | Serial pc(USBTX, USBRX); |
AnkePost | 0:60a8a60074a7 | 8 | |
AnkePost | 1:f6898c9b8c44 | 9 | Servo myservo(D5); |
AnkePost | 1:f6898c9b8c44 | 10 | |
AnkePost | 1:f6898c9b8c44 | 11 | int main() |
AnkePost | 1:f6898c9b8c44 | 12 | { |
AnkePost | 1:f6898c9b8c44 | 13 | for(float p=0; p<1.0; p += 0.1) |
AnkePost | 1:f6898c9b8c44 | 14 | { |
AnkePost | 1:f6898c9b8c44 | 15 | myservo = p; |
AnkePost | 0:60a8a60074a7 | 16 | wait(0.5); |
AnkePost | 1:f6898c9b8c44 | 17 | pc.printf("hello!"); |
AnkePost | 0:60a8a60074a7 | 18 | } |
AnkePost | 0:60a8a60074a7 | 19 | } |