coding for the sub

Dependencies:   mbed Motor Servo

Revision:
5:9825fb56de59
Parent:
4:6feb04db3086
Child:
7:2a445f634f19
--- a/main.cpp	Tue Oct 09 12:41:59 2018 +0000
+++ b/main.cpp	Fri Oct 12 11:59:48 2018 +0000
@@ -7,18 +7,25 @@
 */
 
 
-Motor m(p26, p30, p29);
-Servo myservo(p22);
-float pedal;
+#include "mbed.h"
+#include "stdio.h"
+#include "Motor.h"
+
+DigitalIn sw(p20);
+Motor m(p26,p30,p29);
 
-int main() {
-     while(1){
-    for (pedal=0; pedal<=1 ;pedal+=.25){
-        m.speed(pedal*0.5);
-        pedal = 0;
-        myservo = pedal;
-        //printf("%f", pedal);
-        wait(0.25);
-    }
+int main(){
+    while(1){
+    sw.read();
+if (sw==1)
+{
+    printf("motor on");
+    m.speed(0.5);
 }
+else{
+    printf("motor off");
+m.speed(0.0);
 }
+wait(0.1);
+}
+}
\ No newline at end of file