Beeper zählen

Dependencies:   mbed ur_Bertl

Meine Programme

Beeper zaehlen
Task_3

Files at this revision

API Documentation at this revision

Comitter:
sophia
Date:
Fri May 08 08:47:26 2015 +0000
Parent:
1:e436ca9f7e60
Commit message:
Beeper z?hlen

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e436ca9f7e60 -r c66aa900dd2f main.cpp
--- a/main.cpp	Thu May 07 12:45:43 2015 +0000
+++ b/main.cpp	Fri May 08 08:47:26 2015 +0000
@@ -9,6 +9,7 @@
 {
     ur_Bertl karel;
     int beeper = 0;
+    int weg = 0;
      while(!karel.IsButtonPressed(BTN_FM))
     {
          while(!karel.NextToABeeper())
@@ -19,6 +20,7 @@
         bt.printf("Beeper: %d", beeper);
         
         karel.Move();
+        weg++;
     }
     
     karel.TurnLeft();
@@ -29,4 +31,14 @@
         }
         
     karel.TurnLeft();
+    
+    for (int a = 0; a < weg; a++)
+    karel.Move();
+    
+    karel.TurnLeft();
+    
+    for (int a = 0; a < beeper; a++)
+        {
+            karel.Move();
+        }
 }
\ No newline at end of file