this isn't working the servo just twitches

Dependencies:   Servo mbed Motor

Files at this revision

API Documentation at this revision

Comitter:
Ty
Date:
Thu Oct 23 12:31:39 2014 +0000
Parent:
1:7fa77283f89e
Commit message:
This is the final one boys

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7fa77283f89e -r c754297f78ff Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Thu Oct 23 12:31:39 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/Motor/#c75b234558af
diff -r 7fa77283f89e -r c754297f78ff main.cpp
--- 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 @@
 
     }
 }
+
+
+
+
+
+
+
+ 
+ 
+ 
+
+ 
+
+
+   
+ 
+
+        
+     
+