![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
this isn't working the servo just twitches
Dependencies: Servo mbed Motor
Diff: main.cpp
- Revision:
- 2:c754297f78ff
- Parent:
- 1:7fa77283f89e
--- a/main.cpp Thu Oct 09 14:44:06 2014 +0000 +++ b/main.cpp Thu Oct 23 12:31:39 2014 +0000 @@ -1,19 +1,73 @@ +// Ty LaFramboise, Jin Soo Park, Kevin Saxton +//Project 1 +//Professor Piepmeier + + #include "mbed.h" #include "Servo.h" - +#include "Motor.h" +DigitalIn sw1(p16); + Motor m(p26,p29,p30); + float motspeed=.4; +int count = 0; +int count2 = 0; Servo launchservo(p21); BusOut lights(p5, p6, p7, p8); DigitalIn sw4(p19); +Servo myservo1(p22); //inititalize motors and servo +DigitalIn sw2(p17); +DigitalIn sw3(p18); +float servopos; //current position of servos + float waittime=0.02; int launchswitch; int main() { float i; launchservo=0; while(1) { - - //launchswitch=sw3.read(); + //DC Motor + while (count < 5 && sw1 !=0) {//DC Motor gets power to turn counter clockwise + m.speed(motspeed); + wait(.08); + m.speed(0.0); + wait(.3); + count ++; + } + while (count2 < 5 && sw1 !=0) {//DC Motor gets power to turn clockwise + m.speed(-motspeed); + wait(.08); + m.speed(0.0); + wait(.3); + count2 ++; + + } + count=0; + count2=0; + if(sw1==0) { + + } + // riser servo + if(sw2==1) { + servopos=0.5; + while(sw2==1) { + servopos+=0.0025; + wait(waittime); + myservo1=servopos; + + } + } + if(sw3==1) { + servopos=myservo1; + + while(sw3==1) { + servopos-=0.0025; + wait(waittime); + myservo1=servopos; + } +} + //launch servo if(sw4) { - lights=15; + lights=15;// LED light countdown wait(.5); lights=14; wait(.5); @@ -25,9 +79,10 @@ wait(.5); printf("a\n"); for (i=0; i<=1.0; i+=.01) { - launchservo=i; + launchservo=i;//Turns the servo releasing the plane printf("b\n"); wait(.01); + } @@ -35,3 +90,23 @@ } } + + + + + + + + + + + + + + + + + + + +