![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Kurang Servo Flap
Dependencies: Motor Servo_Test mbed
Fork of Servo_test by
main.cpp@0:ac3026899cce, 2016-10-29 (annotated)
- Committer:
- Joshua23
- Date:
- Sat Oct 29 13:48:08 2016 +0000
- Revision:
- 0:ac3026899cce
- Child:
- 1:d5adf9f6ca32
Servo HelloWorld;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Joshua23 | 0:ac3026899cce | 1 | // Continuously sweep the servo through it's full range |
Joshua23 | 0:ac3026899cce | 2 | #include "mbed.h" |
Joshua23 | 0:ac3026899cce | 3 | #include "Servo.h" |
Joshua23 | 0:ac3026899cce | 4 | |
Joshua23 | 0:ac3026899cce | 5 | Servo myservo(PC_8); |
Joshua23 | 0:ac3026899cce | 6 | |
Joshua23 | 0:ac3026899cce | 7 | int main() { |
Joshua23 | 0:ac3026899cce | 8 | wait_ms(100); |
Joshua23 | 0:ac3026899cce | 9 | myservo.position(-90); |
Joshua23 | 0:ac3026899cce | 10 | wait_ms(2000); |
Joshua23 | 0:ac3026899cce | 11 | while(1) { |
Joshua23 | 0:ac3026899cce | 12 | for(int i=-90; i<=90; i++) { |
Joshua23 | 0:ac3026899cce | 13 | myservo.position(i); |
Joshua23 | 0:ac3026899cce | 14 | wait(0.01); |
Joshua23 | 0:ac3026899cce | 15 | } |
Joshua23 | 0:ac3026899cce | 16 | for(int i=90; i>-90; i--) { |
Joshua23 | 0:ac3026899cce | 17 | myservo.position(i); |
Joshua23 | 0:ac3026899cce | 18 | wait(0.01); |
Joshua23 | 0:ac3026899cce | 19 | } |
Joshua23 | 0:ac3026899cce | 20 | } |
Joshua23 | 0:ac3026899cce | 21 | |
Joshua23 | 0:ac3026899cce | 22 | } |