Sebastian Stroissnigg
/
BeeperZaehler
Fährt und zählt bis Taster (vorne mitte) feuert, gibt dann aus und dreht nach links
Revision 5:306ce06a8b20, committed 2015-05-08
- Comitter:
- SebiStr99
- Date:
- Fri May 08 17:32:05 2015 +0000
- Parent:
- 4:d66cee2c040e
- Commit message:
- F?hrt bis Taster feuert, z?hlt Beeper und gibt sie bei feuer aus
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d66cee2c040e -r 306ce06a8b20 main.cpp --- 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