Markus Watko
/
Button
GoToBeeper2
main.cpp@0:58c13a57ed81, 2015-04-24 (annotated)
- Committer:
- Markus_Watko
- Date:
- Fri Apr 24 08:11:28 2015 +0000
- Revision:
- 0:58c13a57ed81
GoToBeeper2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Markus_Watko | 0:58c13a57ed81 | 1 | #include "mbed.h" |
Markus_Watko | 0:58c13a57ed81 | 2 | #include "ur_Bertl.h" |
Markus_Watko | 0:58c13a57ed81 | 3 | |
Markus_Watko | 0:58c13a57ed81 | 4 | |
Markus_Watko | 0:58c13a57ed81 | 5 | |
Markus_Watko | 0:58c13a57ed81 | 6 | |
Markus_Watko | 0:58c13a57ed81 | 7 | int main() |
Markus_Watko | 0:58c13a57ed81 | 8 | { |
Markus_Watko | 0:58c13a57ed81 | 9 | ur_Bertl karel; |
Markus_Watko | 0:58c13a57ed81 | 10 | |
Markus_Watko | 0:58c13a57ed81 | 11 | bool x = true; |
Markus_Watko | 0:58c13a57ed81 | 12 | int cnt = 0; |
Markus_Watko | 0:58c13a57ed81 | 13 | |
Markus_Watko | 0:58c13a57ed81 | 14 | do |
Markus_Watko | 0:58c13a57ed81 | 15 | { |
Markus_Watko | 0:58c13a57ed81 | 16 | karel.Move(); |
Markus_Watko | 0:58c13a57ed81 | 17 | |
Markus_Watko | 0:58c13a57ed81 | 18 | if (karel.IsButtonPressed(0x80)) |
Markus_Watko | 0:58c13a57ed81 | 19 | { |
Markus_Watko | 0:58c13a57ed81 | 20 | for(int i = 0; i <= 5; i++) |
Markus_Watko | 0:58c13a57ed81 | 21 | { |
Markus_Watko | 0:58c13a57ed81 | 22 | karel.NibbleLeds(0x0F); |
Markus_Watko | 0:58c13a57ed81 | 23 | wait(0.1); |
Markus_Watko | 0:58c13a57ed81 | 24 | karel.NibbleLeds(0x00); |
Markus_Watko | 0:58c13a57ed81 | 25 | wait(0.1); |
Markus_Watko | 0:58c13a57ed81 | 26 | cnt++; |
Markus_Watko | 0:58c13a57ed81 | 27 | } |
Markus_Watko | 0:58c13a57ed81 | 28 | |
Markus_Watko | 0:58c13a57ed81 | 29 | if ( cnt >= 2) |
Markus_Watko | 0:58c13a57ed81 | 30 | { |
Markus_Watko | 0:58c13a57ed81 | 31 | x = false; |
Markus_Watko | 0:58c13a57ed81 | 32 | } |
Markus_Watko | 0:58c13a57ed81 | 33 | |
Markus_Watko | 0:58c13a57ed81 | 34 | karel.MoveBackwards(); |
Markus_Watko | 0:58c13a57ed81 | 35 | karel.TurnLeft(); |
Markus_Watko | 0:58c13a57ed81 | 36 | |
Markus_Watko | 0:58c13a57ed81 | 37 | |
Markus_Watko | 0:58c13a57ed81 | 38 | } |
Markus_Watko | 0:58c13a57ed81 | 39 | |
Markus_Watko | 0:58c13a57ed81 | 40 | |
Markus_Watko | 0:58c13a57ed81 | 41 | }while(x); |
Markus_Watko | 0:58c13a57ed81 | 42 | } |