Sebastian Stroissnigg
/
BeeperZaehler
Fährt und zählt bis Taster (vorne mitte) feuert, gibt dann aus und dreht nach links
main.cpp@5:306ce06a8b20, 2015-05-08 (annotated)
- Committer:
- SebiStr99
- Date:
- Fri May 08 17:32:05 2015 +0000
- Revision:
- 5:306ce06a8b20
- Parent:
- 4:d66cee2c040e
F?hrt bis Taster feuert, z?hlt Beeper und gibt sie bei feuer aus
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SebiStr99 | 0:d50c9e76e8f7 | 1 | #include "mbed.h" |
SebiStr99 | 0:d50c9e76e8f7 | 2 | #include "ur_Bertl.h" |
SebiStr99 | 0:d50c9e76e8f7 | 3 | #include "Beeper_Bertl.h" |
SebiStr99 | 0:d50c9e76e8f7 | 4 | |
SebiStr99 | 0:d50c9e76e8f7 | 5 | Serial bt(p9, p10); |
SebiStr99 | 0:d50c9e76e8f7 | 6 | |
SebiStr99 | 0:d50c9e76e8f7 | 7 | void main() |
SebiStr99 | 0:d50c9e76e8f7 | 8 | { |
SebiStr99 | 0:d50c9e76e8f7 | 9 | Bertl karel; |
SebiStr99 | 0:d50c9e76e8f7 | 10 | |
SebiStr99 | 0:d50c9e76e8f7 | 11 | int Beeper = 0; |
SebiStr99 | 0:d50c9e76e8f7 | 12 | int moves = 0; |
SebiStr99 | 0:d50c9e76e8f7 | 13 | |
SebiStr99 | 0:d50c9e76e8f7 | 14 | while(1) |
SebiStr99 | 0:d50c9e76e8f7 | 15 | { |
SebiStr99 | 5:306ce06a8b20 | 16 | bool stFront = 0; |
SebiStr99 | 5:306ce06a8b20 | 17 | |
SebiStr99 | 5:306ce06a8b20 | 18 | while(!karel.IsButtonPressed(BTN_FM)) |
SebiStr99 | 0:d50c9e76e8f7 | 19 | { |
SebiStr99 | 5:306ce06a8b20 | 20 | stFront = 1; |
SebiStr99 | 3:f92c6d90b328 | 21 | karel.Move(50); |
SebiStr99 | 5:306ce06a8b20 | 22 | moves++; |
SebiStr99 | 5:306ce06a8b20 | 23 | if(karel.NextToABeeper()) |
SebiStr99 | 5:306ce06a8b20 | 24 | { |
SebiStr99 | 5:306ce06a8b20 | 25 | Beeper++; |
SebiStr99 | 5:306ce06a8b20 | 26 | //bt.printf("%i. Beeper", Beeper); |
SebiStr99 | 5:306ce06a8b20 | 27 | karel.Move(50); |
SebiStr99 | 5:306ce06a8b20 | 28 | moves++; |
SebiStr99 | 5:306ce06a8b20 | 29 | } |
SebiStr99 | 5:306ce06a8b20 | 30 | while(karel.NextToABeeper() && !karel.IsButtonPressed(BTN_FM)) |
SebiStr99 | 5:306ce06a8b20 | 31 | { |
SebiStr99 | 5:306ce06a8b20 | 32 | karel.Move(50); |
SebiStr99 | 5:306ce06a8b20 | 33 | moves++; |
SebiStr99 | 5:306ce06a8b20 | 34 | } |
SebiStr99 | 0:d50c9e76e8f7 | 35 | } |
SebiStr99 | 0:d50c9e76e8f7 | 36 | |
SebiStr99 | 5:306ce06a8b20 | 37 | if(stFront == 1) |
SebiStr99 | 5:306ce06a8b20 | 38 | { |
SebiStr99 | 5:306ce06a8b20 | 39 | wait_ms(500); |
SebiStr99 | 5:306ce06a8b20 | 40 | bt.printf("\nGesamt: Moves: %i; Beeper: %i", moves, Beeper); |
SebiStr99 | 5:306ce06a8b20 | 41 | karel.TurnLeft(); |
SebiStr99 | 5:306ce06a8b20 | 42 | } |
SebiStr99 | 0:d50c9e76e8f7 | 43 | } |
SebiStr99 | 0:d50c9e76e8f7 | 44 | } |