Code to fire the ball

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
ihmclachlan
Date:
Tue Nov 28 16:33:52 2017 +0000
Parent:
0:6ca20e4aa3f0
Commit message:
change slight code for servo;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Nov 28 15:54:44 2017 +0000
+++ b/main.cpp	Tue Nov 28 16:33:52 2017 +0000
@@ -56,9 +56,16 @@
                          wait(0.2);
         }
             
-                myservo2 = 1; // remove the lever holding the ball up
+              for(float q=0; q<0.5; q += 0.05) {   // remove the lever holding the ball up
+                 myservo2 = q;
+                wait(0.2); }
+        
                 wait (1);
-                myservo2 = 0;  // put the leaver back into place
+                
+                for(float q=0.5; q>0; q -= 0.05) {  // put the leaver back into place
+                 myservo2 = q;
+                 wait(0.2); }
+         
                 wait (3); // give time for the ball to fire
                 t.start(); // start the timer
                 FMotor = 0; // turn off motors
@@ -88,10 +95,16 @@
                    int r = rand() % 50;
                          wait(0.2);
         }
-            
-                myservo2 = 1; // remove the lever holding the ball up
+            for(float q=0; q<0.5; q += 0.05) {   // remove the lever holding the ball up
+                 myservo2 = q;
+                wait(0.2); }
+        
                 wait (1);
-                myservo2 = 0;  // put the leaver back into place
+                
+                for(float q=0.5; q>0; q -= 0.05) {  // put the leaver back into place
+                 myservo2 = q;
+                 wait(0.2); }
+                 
                 wait (3); // give time for the ball to fire
                 t.start(); // start the timer
                 FMotor = 0; // turn off motors
@@ -119,9 +132,16 @@
                          wait(0.2);
         }
             
-                myservo2 = 1; // remove the lever holding the ball up
+                for(float q=0; q<0.5; q += 0.05) {   // remove the lever holding the ball up
+                 myservo2 = q;
+                wait(0.2); }
+        
                 wait (1);
-                myservo2 = 0;  // put the leaver back into place
+                
+                for(float q=0.5; q>0; q -= 0.05) {  // put the leaver back into place
+                 myservo2 = q;
+                 wait(0.2); }
+                 
                 wait (3); // give time for the ball to fire
                 t.start(); // start the timer
                 FMotor = 0; // turn off motors