Beeper zählen

Dependencies:   mbed ur_Bertl

Meine Programme

Beeper zaehlen
Task_3

Committer:
sophia
Date:
Thu May 07 12:45:43 2015 +0000
Revision:
1:e436ca9f7e60
Parent:
0:29ba97aa379f
Child:
2:c66aa900dd2f
Beeper z?hlen mit Ausgabe

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sophia 0:29ba97aa379f 1 #include "mbed.h"
sophia 0:29ba97aa379f 2 #include "ur_Bertl.h"
sophia 1:e436ca9f7e60 3 #include "const.h"
sophia 0:29ba97aa379f 4
sophia 0:29ba97aa379f 5
sophia 0:29ba97aa379f 6 Serial bt(p9, p10);
sophia 0:29ba97aa379f 7
sophia 0:29ba97aa379f 8 int main ()
sophia 0:29ba97aa379f 9 {
sophia 0:29ba97aa379f 10 ur_Bertl karel;
sophia 0:29ba97aa379f 11 int beeper = 0;
sophia 1:e436ca9f7e60 12 while(!karel.IsButtonPressed(BTN_FM))
sophia 0:29ba97aa379f 13 {
sophia 0:29ba97aa379f 14 while(!karel.NextToABeeper())
sophia 0:29ba97aa379f 15 {
sophia 0:29ba97aa379f 16 karel.Move();
sophia 0:29ba97aa379f 17 }
sophia 0:29ba97aa379f 18 beeper++;
sophia 1:e436ca9f7e60 19 bt.printf("Beeper: %d", beeper);
sophia 0:29ba97aa379f 20
sophia 0:29ba97aa379f 21 karel.Move();
sophia 0:29ba97aa379f 22 }
sophia 0:29ba97aa379f 23
sophia 0:29ba97aa379f 24 karel.TurnLeft();
sophia 0:29ba97aa379f 25
sophia 0:29ba97aa379f 26 for (int a = 0; a < beeper; a++)
sophia 0:29ba97aa379f 27 {
sophia 0:29ba97aa379f 28 karel.Move();
sophia 0:29ba97aa379f 29 }
sophia 0:29ba97aa379f 30
sophia 0:29ba97aa379f 31 karel.TurnLeft();
sophia 0:29ba97aa379f 32 }