coding for the sub

Dependencies:   mbed Motor Servo

Revision:
7:2a445f634f19
Parent:
5:9825fb56de59
Child:
8:ef878ee3f536
--- a/main.cpp	Fri Oct 12 11:59:48 2018 +0000
+++ b/main.cpp	Tue Oct 16 12:00:48 2018 +0000
@@ -7,10 +7,6 @@
 */
 
 
-#include "mbed.h"
-#include "stdio.h"
-#include "Motor.h"
-
 DigitalIn sw(p20);
 Motor m(p26,p30,p29);
 
@@ -28,4 +24,35 @@
 }
 wait(0.1);
 }
+}
+
+DigitalIn sw2(p19);
+Servo t(p22);
+float pos = 0.0;
+int main(){
+    t.calibrate(0.0009, 90.0);
+    t = pos; 
+    while(1){
+    sw2.read();
+if (sw2.read()==1)
+{
+    printf("servo on");
+    for(int x=0; x<50; x++)
+    { t=x/100.0;
+    
+    
+    wait(0.10);
+    }
+    for(int x=50;x>0;x--){
+        t = x/100.0;
+        
+        wait(0.10);
+    }
+    
+}
+else{
+    printf("servo off");
+}
+wait(0.1);
+}
 }
\ No newline at end of file