![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ECE 4180 Lab 2 Servo
Fork of Servo_HelloWorld by
main.cpp@2:a972a1a76954, 2016-02-15 (annotated)
- Committer:
- dhcabinian
- Date:
- Mon Feb 15 17:36:42 2016 +0000
- Revision:
- 2:a972a1a76954
- Parent:
- 1:40d2fd0b99e6
4180L2_Servo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 1:40d2fd0b99e6 | 1 | // Hello World to sweep a servo through its full range |
simon | 1:40d2fd0b99e6 | 2 | |
simon | 1:40d2fd0b99e6 | 3 | #include "mbed.h" |
simon | 1:40d2fd0b99e6 | 4 | #include "Servo.h" |
simon | 1:40d2fd0b99e6 | 5 | |
simon | 1:40d2fd0b99e6 | 6 | Servo myservo(p21); |
simon | 1:40d2fd0b99e6 | 7 | |
simon | 1:40d2fd0b99e6 | 8 | int main() { |
simon | 1:40d2fd0b99e6 | 9 | for(float p=0; p<1.0; p += 0.1) { |
simon | 1:40d2fd0b99e6 | 10 | myservo = p; |
simon | 1:40d2fd0b99e6 | 11 | wait(0.2); |
simon | 1:40d2fd0b99e6 | 12 | } |
dhcabinian | 2:a972a1a76954 | 13 | |
dhcabinian | 2:a972a1a76954 | 14 | wait(10); |
dhcabinian | 2:a972a1a76954 | 15 | |
dhcabinian | 2:a972a1a76954 | 16 | for(float p=1.0; p>=0; p -= 0.2) { |
dhcabinian | 2:a972a1a76954 | 17 | myservo = p; |
dhcabinian | 2:a972a1a76954 | 18 | wait(0.2); |
dhcabinian | 2:a972a1a76954 | 19 | } |
simon | 1:40d2fd0b99e6 | 20 | } |