Antonia Baumgartner / Mbed 2 deprecated YB_copy

Dependencies:   mbed

Fork of Versuch21 by Antonia Baumgartner

Revision:
4:3c6d2c035243
Parent:
3:f44ef28cfb2d
Child:
5:93d3efe46493
--- a/main.cpp	Sun Apr 29 11:29:00 2018 +0000
+++ b/main.cpp	Tue May 01 11:42:38 2018 +0000
@@ -12,7 +12,7 @@
 //------------------------------------------------------------------------------
 
 //Motorbefehle von LHR
-int D, sl, sr, X;
+int D, sl, sr;
 Timer timey;
 
 //------------------------------------------------------------------------------
@@ -23,8 +23,10 @@
 AnalogIn sensorValue4(PB_1);        // Seitlicher Sensor links
 AnalogIn sensorValue5(PA_4);        // Seitlicher Sensor rechts
 AnalogIn sensorValue6(PB_0);        // Helligkeitssensor
-DigitalOut myled(LED1);             // LED 1
-InterruptIn button(USER_BUTTON);      // Startknopf
+//DigitalOut myled(LED1);           // LED 1
+//InterruptIn button(USER_BUTTON);  // Startknopf
+DigitalIn mybutton(USER_BUTTON);
+DigitalOut myled(LED1);
 DigitalOut power_5v(PC_4);          // 5V auf Sensoren, geschalten
 
 DigitalOut enable(PC_1);
@@ -63,15 +65,16 @@
     LHR LHR(Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6);
     Spurhaltung spurhaltung(Sensor2, Sensor3);
     Motion motion(counterLeft, counterRight, controller, spurhaltung, Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6);
-    
+
+    while(1) {
 
-            
-        while (1) {
-            //D = LHR.moving();            
-            printf("X: %d\r\n", X);
-            button.rise(X = 1);
-            //motion.switching(D);        
-            
-       // }
+        if (mybutton == 0) { // Button is pressed
+            wait(1);
+            while (1) {
+                D = LHR.moving();
+                motion.switching(D);
+                wait(0.2);
+            }
+        }
     }
-}
\ No newline at end of file
+    }