![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Bertl
main.cpp@0:9f717595fa8b, 2015-12-21 (annotated)
- Committer:
- Michi_Jocham
- Date:
- Mon Dec 21 14:31:11 2015 +0000
- Revision:
- 0:9f717595fa8b
bertl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Michi_Jocham | 0:9f717595fa8b | 1 | #include "mbed.h" |
Michi_Jocham | 0:9f717595fa8b | 2 | #include "const.h" |
Michi_Jocham | 0:9f717595fa8b | 3 | #include "Robot.h" |
Michi_Jocham | 0:9f717595fa8b | 4 | #include "ur_Bertl.h" |
Michi_Jocham | 0:9f717595fa8b | 5 | Robot bertl; |
Michi_Jocham | 0:9f717595fa8b | 6 | bool Ultraschallsensor () |
Michi_Jocham | 0:9f717595fa8b | 7 | { |
Michi_Jocham | 0:9f717595fa8b | 8 | if(bertl.FrontIsClear()) |
Michi_Jocham | 0:9f717595fa8b | 9 | { |
Michi_Jocham | 0:9f717595fa8b | 10 | return true; |
Michi_Jocham | 0:9f717595fa8b | 11 | } |
Michi_Jocham | 0:9f717595fa8b | 12 | else |
Michi_Jocham | 0:9f717595fa8b | 13 | { |
Michi_Jocham | 0:9f717595fa8b | 14 | return false; |
Michi_Jocham | 0:9f717595fa8b | 15 | } |
Michi_Jocham | 0:9f717595fa8b | 16 | |
Michi_Jocham | 0:9f717595fa8b | 17 | } |
Michi_Jocham | 0:9f717595fa8b | 18 | void Alarmblinkanlage () |
Michi_Jocham | 0:9f717595fa8b | 19 | { |
Michi_Jocham | 0:9f717595fa8b | 20 | bertl.TurnLedOn(LED_ALL_FRONT); |
Michi_Jocham | 0:9f717595fa8b | 21 | bertl.TurnLedOn(LED_ALL_BACK); |
Michi_Jocham | 0:9f717595fa8b | 22 | wait(0.1); |
Michi_Jocham | 0:9f717595fa8b | 23 | bertl.TurnLedOff(LED_ALL_FRONT); |
Michi_Jocham | 0:9f717595fa8b | 24 | bertl.TurnLedOff(LED_ALL_BACK); |
Michi_Jocham | 0:9f717595fa8b | 25 | |
Michi_Jocham | 0:9f717595fa8b | 26 | } |
Michi_Jocham | 0:9f717595fa8b | 27 | void FrontscheinwerferAn () |
Michi_Jocham | 0:9f717595fa8b | 28 | { |
Michi_Jocham | 0:9f717595fa8b | 29 | bertl.TurnLedOn(LED_FL1); |
Michi_Jocham | 0:9f717595fa8b | 30 | bertl.TurnLedOn(LED_FR1); |
Michi_Jocham | 0:9f717595fa8b | 31 | } |
Michi_Jocham | 0:9f717595fa8b | 32 | void FrontscheinwerferAus () |
Michi_Jocham | 0:9f717595fa8b | 33 | { |
Michi_Jocham | 0:9f717595fa8b | 34 | bertl.TurnLedOff(LED_FL1); |
Michi_Jocham | 0:9f717595fa8b | 35 | bertl.TurnLedOff(LED_FR1); |
Michi_Jocham | 0:9f717595fa8b | 36 | } |
Michi_Jocham | 0:9f717595fa8b | 37 | |
Michi_Jocham | 0:9f717595fa8b | 38 | |
Michi_Jocham | 0:9f717595fa8b | 39 | |
Michi_Jocham | 0:9f717595fa8b | 40 | void BlinkenLinks() |
Michi_Jocham | 0:9f717595fa8b | 41 | { |
Michi_Jocham | 0:9f717595fa8b | 42 | int a=0; |
Michi_Jocham | 0:9f717595fa8b | 43 | int b=1; |
Michi_Jocham | 0:9f717595fa8b | 44 | while(a<b) |
Michi_Jocham | 0:9f717595fa8b | 45 | { |
Michi_Jocham | 0:9f717595fa8b | 46 | bertl.TurnLedOn(LED_BL1); |
Michi_Jocham | 0:9f717595fa8b | 47 | bertl.TurnLedOn(LED_FL2); |
Michi_Jocham | 0:9f717595fa8b | 48 | wait(0.1); |
Michi_Jocham | 0:9f717595fa8b | 49 | bertl.TurnLedOff(LED_BL1); |
Michi_Jocham | 0:9f717595fa8b | 50 | bertl.TurnLedOff(LED_FL2); |
Michi_Jocham | 0:9f717595fa8b | 51 | a++; |
Michi_Jocham | 0:9f717595fa8b | 52 | } |
Michi_Jocham | 0:9f717595fa8b | 53 | } |
Michi_Jocham | 0:9f717595fa8b | 54 | |
Michi_Jocham | 0:9f717595fa8b | 55 | |
Michi_Jocham | 0:9f717595fa8b | 56 | void BlinkenRechts() |
Michi_Jocham | 0:9f717595fa8b | 57 | { |
Michi_Jocham | 0:9f717595fa8b | 58 | int a=0; |
Michi_Jocham | 0:9f717595fa8b | 59 | int b=1; |
Michi_Jocham | 0:9f717595fa8b | 60 | while(a<b) |
Michi_Jocham | 0:9f717595fa8b | 61 | { |
Michi_Jocham | 0:9f717595fa8b | 62 | bertl.TurnLedOn(LED_FR2); |
Michi_Jocham | 0:9f717595fa8b | 63 | bertl.TurnLedOn(LED_BR2); |
Michi_Jocham | 0:9f717595fa8b | 64 | wait(0.1); |
Michi_Jocham | 0:9f717595fa8b | 65 | bertl.TurnLedOff(LED_FR2); |
Michi_Jocham | 0:9f717595fa8b | 66 | bertl.TurnLedOff(LED_BR2); |
Michi_Jocham | 0:9f717595fa8b | 67 | a++; |
Michi_Jocham | 0:9f717595fa8b | 68 | } |
Michi_Jocham | 0:9f717595fa8b | 69 | } |
Michi_Jocham | 0:9f717595fa8b | 70 | |
Michi_Jocham | 0:9f717595fa8b | 71 | |
Michi_Jocham | 0:9f717595fa8b | 72 | |
Michi_Jocham | 0:9f717595fa8b | 73 | int main() |
Michi_Jocham | 0:9f717595fa8b | 74 | { |
Michi_Jocham | 0:9f717595fa8b | 75 | |
Michi_Jocham | 0:9f717595fa8b | 76 | |
Michi_Jocham | 0:9f717595fa8b | 77 | while(1) |
Michi_Jocham | 0:9f717595fa8b | 78 | { |
Michi_Jocham | 0:9f717595fa8b | 79 | |
Michi_Jocham | 0:9f717595fa8b | 80 | |
Michi_Jocham | 0:9f717595fa8b | 81 | if(Ultraschallsensor()) |
Michi_Jocham | 0:9f717595fa8b | 82 | { |
Michi_Jocham | 0:9f717595fa8b | 83 | Alarmblinkanlage(); |
Michi_Jocham | 0:9f717595fa8b | 84 | bertl.MoveBackwards(); |
Michi_Jocham | 0:9f717595fa8b | 85 | BlinkenLinks(); |
Michi_Jocham | 0:9f717595fa8b | 86 | bertl.TurnLeft(); |
Michi_Jocham | 0:9f717595fa8b | 87 | bertl.Move(); |
Michi_Jocham | 0:9f717595fa8b | 88 | BlinkenRechts(); |
Michi_Jocham | 0:9f717595fa8b | 89 | bertl.TurnRigth(); |
Michi_Jocham | 0:9f717595fa8b | 90 | } |
Michi_Jocham | 0:9f717595fa8b | 91 | else |
Michi_Jocham | 0:9f717595fa8b | 92 | { |
Michi_Jocham | 0:9f717595fa8b | 93 | bertl.Move(); |
Michi_Jocham | 0:9f717595fa8b | 94 | } |
Michi_Jocham | 0:9f717595fa8b | 95 | |
Michi_Jocham | 0:9f717595fa8b | 96 | } |
Michi_Jocham | 0:9f717595fa8b | 97 | } |