Martin Werluschnig
/
Rasenmaeher_Angabe
Rasenmaeher_Angabe
RasenMaeher.cpp@5:952090ddc8eb, 2018-06-12 (annotated)
- Committer:
- hollegha2
- Date:
- Tue Jun 12 11:19:48 2018 +0000
- Revision:
- 5:952090ddc8eb
- Child:
- 6:5d2d394eb087
xx3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hollegha2 | 5:952090ddc8eb | 1 | |
hollegha2 | 5:952090ddc8eb | 2 | #include "mbed.h" |
hollegha2 | 5:952090ddc8eb | 3 | #include "Serial_HL.h" |
hollegha2 | 5:952090ddc8eb | 4 | #include "Bertl14.h" |
hollegha2 | 5:952090ddc8eb | 5 | #include "BertlObjects.h" |
hollegha2 | 5:952090ddc8eb | 6 | |
hollegha2 | 5:952090ddc8eb | 7 | // main=2^0 LS ENC 2^2 |
hollegha2 | 5:952090ddc8eb | 8 | BusOut boardPow(p30, P1_6, P1_7); |
hollegha2 | 5:952090ddc8eb | 9 | AnalogInHL ls1(p18), ls2(p16), ls3(p20), ls4(p19), ls5(p17); // B15 |
hollegha2 | 5:952090ddc8eb | 10 | |
hollegha2 | 5:952090ddc8eb | 11 | // Alle Funktionen die den Bertl bewegen werden mit |
hollegha2 | 5:952090ddc8eb | 12 | // ausgeschalteten Motoren betreten und mit ausgeschalteten Motoren |
hollegha2 | 5:952090ddc8eb | 13 | // wieder verlassen |
hollegha2 | 5:952090ddc8eb | 14 | |
hollegha2 | 5:952090ddc8eb | 15 | void ForewardUntilWall(); |
hollegha2 | 5:952090ddc8eb | 16 | |
hollegha2 | 5:952090ddc8eb | 17 | void SomeStepsBack(); |
hollegha2 | 5:952090ddc8eb | 18 | |
hollegha2 | 5:952090ddc8eb | 19 | void TurnLeft(); |
hollegha2 | 5:952090ddc8eb | 20 | |
hollegha2 | 5:952090ddc8eb | 21 | void TurnRight(); |
hollegha2 | 5:952090ddc8eb | 22 | |
hollegha2 | 5:952090ddc8eb | 23 | void FrontBlinkerTask(); |
hollegha2 | 5:952090ddc8eb | 24 | |
hollegha2 | 5:952090ddc8eb | 25 | void BackBlinkerTask(); |
hollegha2 | 5:952090ddc8eb | 26 | |
hollegha2 | 5:952090ddc8eb | 27 | // Line==left ret 1 Line==right ret 2 |
hollegha2 | 5:952090ddc8eb | 28 | int CheckLineSensors(); |
hollegha2 | 5:952090ddc8eb | 29 | |
hollegha2 | 5:952090ddc8eb | 30 | int main(void) |
hollegha2 | 5:952090ddc8eb | 31 | { |
hollegha2 | 5:952090ddc8eb | 32 | boardPow=3; wait_ms(10); |
hollegha2 | 5:952090ddc8eb | 33 | InitBertl(); leds=9; |
hollegha2 | 5:952090ddc8eb | 34 | pex.ClearLeds(); |
hollegha2 | 5:952090ddc8eb | 35 | |
hollegha2 | 5:952090ddc8eb | 36 | int dir; |
hollegha2 | 5:952090ddc8eb | 37 | while(1) |
hollegha2 | 5:952090ddc8eb | 38 | { |
hollegha2 | 5:952090ddc8eb | 39 | ForewardUntilWall(); |
hollegha2 | 5:952090ddc8eb | 40 | dir = CheckLineSensors(); |
hollegha2 | 5:952090ddc8eb | 41 | wait_ms(200); // for debugging |
hollegha2 | 5:952090ddc8eb | 42 | SomeStepsBack(); |
hollegha2 | 5:952090ddc8eb | 43 | wait_ms(200); // for debugging |
hollegha2 | 5:952090ddc8eb | 44 | if( dir==1 ) |
hollegha2 | 5:952090ddc8eb | 45 | TurnLeft(); |
hollegha2 | 5:952090ddc8eb | 46 | else |
hollegha2 | 5:952090ddc8eb | 47 | TurnRight(); |
hollegha2 | 5:952090ddc8eb | 48 | wait_ms(200); // for debugging |
hollegha2 | 5:952090ddc8eb | 49 | } |
hollegha2 | 5:952090ddc8eb | 50 | |
hollegha2 | 5:952090ddc8eb | 51 | return 1; |
hollegha2 | 5:952090ddc8eb | 52 | } |
hollegha2 | 5:952090ddc8eb | 53 | |
hollegha2 | 5:952090ddc8eb | 54 | void ForewardUntilWall() |
hollegha2 | 5:952090ddc8eb | 55 | { |
hollegha2 | 5:952090ddc8eb | 56 | // Motorten einschalten |
hollegha2 | 5:952090ddc8eb | 57 | while(1) |
hollegha2 | 5:952090ddc8eb | 58 | { |
hollegha2 | 5:952090ddc8eb | 59 | FrontBlinkerTask(); |
hollegha2 | 5:952090ddc8eb | 60 | // CheckLineSensors(); |
hollegha2 | 5:952090ddc8eb | 61 | // für Aufgabe 3 CheckButtons() |
hollegha2 | 5:952090ddc8eb | 62 | // if( Button_pressed or LinSensor ) |
hollegha2 | 5:952090ddc8eb | 63 | // break; |
hollegha2 | 5:952090ddc8eb | 64 | } |
hollegha2 | 5:952090ddc8eb | 65 | // Motoren ausschalten |
hollegha2 | 5:952090ddc8eb | 66 | } |
hollegha2 | 5:952090ddc8eb | 67 | |
hollegha2 | 5:952090ddc8eb | 68 | void SomeStepsBack() |
hollegha2 | 5:952090ddc8eb | 69 | { |
hollegha2 | 5:952090ddc8eb | 70 | // Motoren auf rückwärts |
hollegha2 | 5:952090ddc8eb | 71 | // wait_ms(100); |
hollegha2 | 5:952090ddc8eb | 72 | // Motoren ausschalten |
hollegha2 | 5:952090ddc8eb | 73 | } |
hollegha2 | 5:952090ddc8eb | 74 | |
hollegha2 | 5:952090ddc8eb | 75 | void TurnLeft() |
hollegha2 | 5:952090ddc8eb | 76 | { |
hollegha2 | 5:952090ddc8eb | 77 | } |
hollegha2 | 5:952090ddc8eb | 78 | |
hollegha2 | 5:952090ddc8eb | 79 | void TurnRight() |
hollegha2 | 5:952090ddc8eb | 80 | { |
hollegha2 | 5:952090ddc8eb | 81 | } |
hollegha2 | 5:952090ddc8eb | 82 | |
hollegha2 | 5:952090ddc8eb | 83 | void FrontBlinkerTask() |
hollegha2 | 5:952090ddc8eb | 84 | { |
hollegha2 | 5:952090ddc8eb | 85 | } |
hollegha2 | 5:952090ddc8eb | 86 | |
hollegha2 | 5:952090ddc8eb | 87 | void BackBlinkerTask() |
hollegha2 | 5:952090ddc8eb | 88 | { |
hollegha2 | 5:952090ddc8eb | 89 | } |
hollegha2 | 5:952090ddc8eb | 90 |