![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
this isn't working the servo just twitches
Dependencies: Servo mbed Motor
main.cpp@1:7fa77283f89e, 2014-10-09 (annotated)
- Committer:
- Ty
- Date:
- Thu Oct 09 14:44:06 2014 +0000
- Revision:
- 1:7fa77283f89e
- Parent:
- 0:22157cad3c1e
- Child:
- 2:c754297f78ff
It's working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ty | 0:22157cad3c1e | 1 | #include "mbed.h" |
Ty | 0:22157cad3c1e | 2 | #include "Servo.h" |
Ty | 0:22157cad3c1e | 3 | |
Ty | 0:22157cad3c1e | 4 | Servo launchservo(p21); |
Ty | 1:7fa77283f89e | 5 | BusOut lights(p5, p6, p7, p8); |
Ty | 1:7fa77283f89e | 6 | DigitalIn sw4(p19); |
Ty | 0:22157cad3c1e | 7 | int launchswitch; |
Ty | 1:7fa77283f89e | 8 | int main() |
Ty | 1:7fa77283f89e | 9 | { |
Ty | 1:7fa77283f89e | 10 | float i; |
Ty | 0:22157cad3c1e | 11 | launchservo=0; |
Ty | 1:7fa77283f89e | 12 | while(1) { |
Ty | 1:7fa77283f89e | 13 | |
Ty | 1:7fa77283f89e | 14 | //launchswitch=sw3.read(); |
Ty | 1:7fa77283f89e | 15 | if(sw4) { |
Ty | 1:7fa77283f89e | 16 | lights=15; |
Ty | 1:7fa77283f89e | 17 | wait(.5); |
Ty | 1:7fa77283f89e | 18 | lights=14; |
Ty | 1:7fa77283f89e | 19 | wait(.5); |
Ty | 1:7fa77283f89e | 20 | lights=12; |
Ty | 1:7fa77283f89e | 21 | wait(.5); |
Ty | 1:7fa77283f89e | 22 | lights=8; |
Ty | 1:7fa77283f89e | 23 | wait(.5); |
Ty | 1:7fa77283f89e | 24 | lights=0; |
Ty | 1:7fa77283f89e | 25 | wait(.5); |
Ty | 1:7fa77283f89e | 26 | printf("a\n"); |
Ty | 1:7fa77283f89e | 27 | for (i=0; i<=1.0; i+=.01) { |
Ty | 1:7fa77283f89e | 28 | launchservo=i; |
Ty | 1:7fa77283f89e | 29 | printf("b\n"); |
Ty | 1:7fa77283f89e | 30 | wait(.01); |
Ty | 1:7fa77283f89e | 31 | |
Ty | 1:7fa77283f89e | 32 | } |
Ty | 1:7fa77283f89e | 33 | |
Ty | 1:7fa77283f89e | 34 | } |
Ty | 1:7fa77283f89e | 35 | |
Ty | 0:22157cad3c1e | 36 | } |
Ty | 1:7fa77283f89e | 37 | } |