Start of project 2

Dependencies:   Motor Servo mbed mbed-rtos

Revision:
1:7133819e4265
Parent:
0:9347308e8e1a
Child:
2:60a8105d0d20
--- a/main.cpp	Tue Oct 09 12:22:19 2018 +0000
+++ b/main.cpp	Tue Oct 09 13:30:18 2018 +0000
@@ -3,20 +3,36 @@
 #include "Motor.h"
 #include "math.h"
 
+int s1, s3, s4, i;
+DigitalIn swtch1(p19);
+DigitalIn swtch3(p20);
+DigitalIn swtch4(p21);
 
 Motor m(p26, p30, p29);
-int i;
-char x;
-int j;
+
+Servo back(p21);
+Servo angle(p22);
 
 int main() {
+    s1 = swtch1.read(); //read state of switch 1
+    back.calibrate(0.0009, 90.0); //calculate's servos timing by setting pulse width and range
     
-    while(1){
-        m.speed(1);
-        getchar();
-        m.speed(-1);
-        getchar();  
-    } //end of while loop
-    
+    while (s1 == 1)
+    {
+       for (i = 0; i < 18; i++) //moves monument forward
+       {
+       back = 0;
+       back = (0.0 + (i/18.0));
+     s1 = swtch1.read(); //read state of switch 1
+      }//end of for loop
+      
+      for (i = 0; i < 35; i++)  //moves monument backwards
+       {
+       back = 1;
+       back = (1.0 - (i/18.0));
+     s1 = swtch1.read(); //read state of switch 1
+      }//end of for loop
+      
+      }//end of while loop
+      
     } //end of int main
-    
\ No newline at end of file