Sebastian Stroissnigg
/
BeeperZaehler
Fährt und zählt bis Taster (vorne mitte) feuert, gibt dann aus und dreht nach links
Diff: main.cpp
- Revision:
- 5:306ce06a8b20
- Parent:
- 4:d66cee2c040e
--- a/main.cpp Fri May 08 16:28:35 2015 +0000 +++ b/main.cpp Fri May 08 17:32:05 2015 +0000 @@ -13,22 +13,32 @@ while(1) { - karel.Move(50); - moves++; - if(karel.NextToABeeper()) + bool stFront = 0; + + while(!karel.IsButtonPressed(BTN_FM)) { - Beeper++; - //bt.printf("%i. Beeper", Beeper); + stFront = 1; karel.Move(50); - moves++; - } - while(karel.NextToABeeper()) - { - karel.Move(50); - moves++; + moves++; + if(karel.NextToABeeper()) + { + Beeper++; + //bt.printf("%i. Beeper", Beeper); + karel.Move(50); + moves++; + } + while(karel.NextToABeeper() && !karel.IsButtonPressed(BTN_FM)) + { + karel.Move(50); + moves++; + } } - bt.printf("\nGesamt: Moves: %i; Beeper: %i", moves, Beeper); - karel.ShutOff(); + if(stFront == 1) + { + wait_ms(500); + bt.printf("\nGesamt: Moves: %i; Beeper: %i", moves, Beeper); + karel.TurnLeft(); + } } } \ No newline at end of file