![](/media/cache/group/memeMan.png.50x50_q85.png)
Daniel Kahr
Dependencies: mbed
Fork of Lektion02b_Kahr by
main.cpp@4:25f04078bca4, 2016-01-29 (annotated)
- Committer:
- DanielKahr
- Date:
- Fri Jan 29 13:37:52 2016 +0000
- Revision:
- 4:25f04078bca4
- Parent:
- 3:6acee5d90cd0
d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:fe5e1c689c26 | 1 | #include "mbed.h" |
Enenkel | 1:52e206dbe635 | 2 | // HIMBED Lektion_02b "Lauflicht über 12 LED" |
Enenkel | 0:fe5e1c689c26 | 3 | // by Gottfried ENENKEL 2014-12-12 |
Enenkel | 0:fe5e1c689c26 | 4 | // AUFGABE: |
Enenkel | 0:fe5e1c689c26 | 5 | // Verändere dis Software sie so, dass ein Lauflicht mit je 2 LED |
Enenkel | 0:fe5e1c689c26 | 6 | // über den 12 LED Balken des HIMBED entsteht |
Enenkel | 0:fe5e1c689c26 | 7 | // Das Lauflicht soll hin und her gleiten. |
Enenkel | 0:fe5e1c689c26 | 8 | // Am Anfang und am Ende sollen alle LED aus sein. |
Enenkel | 0:fe5e1c689c26 | 9 | // |
Enenkel | 0:fe5e1c689c26 | 10 | // DEFINITIONEN ************************************************* |
Enenkel | 0:fe5e1c689c26 | 11 | // Ausgange definieren: |
Enenkel | 0:fe5e1c689c26 | 12 | DigitalOut LedD1 (P1_8); |
Enenkel | 0:fe5e1c689c26 | 13 | DigitalOut LedD2 (P1_9); |
DanielKahr | 3:6acee5d90cd0 | 14 | DigitalOut LedD3 (P1_10); |
DanielKahr | 3:6acee5d90cd0 | 15 | DigitalOut LedD4 (P1_11); |
Enenkel | 0:fe5e1c689c26 | 16 | DigitalOut LedD13 (P1_0); //D13 geht auf EP10 und dieser auf Port0 Pin0 |
Enenkel | 0:fe5e1c689c26 | 17 | DigitalOut LedD14 (P1_1); |
DanielKahr | 3:6acee5d90cd0 | 18 | DigitalOut LedD15 (P1_3); |
DanielKahr | 3:6acee5d90cd0 | 19 | DigitalOut LedD16 (P1_4); |
DanielKahr | 3:6acee5d90cd0 | 20 | DigitalOut LedD17 (P1_6); |
DanielKahr | 3:6acee5d90cd0 | 21 | DigitalOut LedD18 (P1_7); |
DanielKahr | 3:6acee5d90cd0 | 22 | DigitalOut LedD19 (P1_12); |
DanielKahr | 3:6acee5d90cd0 | 23 | DigitalOut LedD20 (P1_13); |
Enenkel | 0:fe5e1c689c26 | 24 | // hier ergänzen bis D20 |
Enenkel | 0:fe5e1c689c26 | 25 | |
Enenkel | 0:fe5e1c689c26 | 26 | // HAUPTPROGRAMM *********************************************** |
Enenkel | 2:46da9f6bc48c | 27 | int main() |
Enenkel | 2:46da9f6bc48c | 28 | { |
Enenkel | 0:fe5e1c689c26 | 29 | while(1) // Hauptschleife |
Enenkel | 0:fe5e1c689c26 | 30 | { |
Enenkel | 0:fe5e1c689c26 | 31 | LedD1=1; // LED D1 EIN |
DanielKahr | 4:25f04078bca4 | 32 | wait(0.1); // warte 0.1 sec |
Enenkel | 0:fe5e1c689c26 | 33 | LedD2=1; // LED D2 EIN |
DanielKahr | 4:25f04078bca4 | 34 | wait (0.1); // warte 0.1 sec |
Enenkel | 0:fe5e1c689c26 | 35 | LedD1=0; |
DanielKahr | 4:25f04078bca4 | 36 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 37 | LedD2=0; |
DanielKahr | 4:25f04078bca4 | 38 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 39 | |
DanielKahr | 3:6acee5d90cd0 | 40 | LedD3=1; |
DanielKahr | 4:25f04078bca4 | 41 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 42 | LedD4=1; |
DanielKahr | 4:25f04078bca4 | 43 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 44 | LedD3=0; |
DanielKahr | 4:25f04078bca4 | 45 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 46 | LedD4=0; |
DanielKahr | 4:25f04078bca4 | 47 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 48 | |
Enenkel | 0:fe5e1c689c26 | 49 | LedD13=1; |
DanielKahr | 4:25f04078bca4 | 50 | wait (0.1); |
Enenkel | 0:fe5e1c689c26 | 51 | LedD14=1; |
DanielKahr | 4:25f04078bca4 | 52 | wait (0.1); |
Enenkel | 0:fe5e1c689c26 | 53 | LedD13=0; |
DanielKahr | 4:25f04078bca4 | 54 | wait (0.1); |
Enenkel | 0:fe5e1c689c26 | 55 | LedD14=0; |
DanielKahr | 4:25f04078bca4 | 56 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 57 | |
DanielKahr | 3:6acee5d90cd0 | 58 | LedD15=1; |
DanielKahr | 4:25f04078bca4 | 59 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 60 | LedD16=1; |
DanielKahr | 4:25f04078bca4 | 61 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 62 | LedD15=0; |
DanielKahr | 4:25f04078bca4 | 63 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 64 | LedD16=0; |
DanielKahr | 4:25f04078bca4 | 65 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 66 | |
DanielKahr | 3:6acee5d90cd0 | 67 | LedD17=1; |
DanielKahr | 4:25f04078bca4 | 68 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 69 | LedD18=1; |
DanielKahr | 4:25f04078bca4 | 70 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 71 | LedD17=0; |
DanielKahr | 4:25f04078bca4 | 72 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 73 | LedD18=0; |
DanielKahr | 4:25f04078bca4 | 74 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 75 | |
DanielKahr | 4:25f04078bca4 | 76 | LedD19=1; |
DanielKahr | 4:25f04078bca4 | 77 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 78 | LedD20=1; |
DanielKahr | 4:25f04078bca4 | 79 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 80 | LedD19=0; |
DanielKahr | 4:25f04078bca4 | 81 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 82 | LedD20=0; |
DanielKahr | 4:25f04078bca4 | 83 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 84 | |
DanielKahr | 4:25f04078bca4 | 85 | LedD20=1; |
DanielKahr | 4:25f04078bca4 | 86 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 87 | LedD19=1; |
DanielKahr | 4:25f04078bca4 | 88 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 89 | LedD20=0; |
DanielKahr | 4:25f04078bca4 | 90 | wait (0.1); |
DanielKahr | 3:6acee5d90cd0 | 91 | LedD19=0; |
DanielKahr | 4:25f04078bca4 | 92 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 93 | |
DanielKahr | 4:25f04078bca4 | 94 | LedD18=1; |
DanielKahr | 4:25f04078bca4 | 95 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 96 | LedD17=1; |
DanielKahr | 4:25f04078bca4 | 97 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 98 | LedD18=0; |
DanielKahr | 4:25f04078bca4 | 99 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 100 | LedD17=0; |
DanielKahr | 4:25f04078bca4 | 101 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 102 | |
DanielKahr | 4:25f04078bca4 | 103 | LedD16=1; |
DanielKahr | 4:25f04078bca4 | 104 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 105 | LedD15=1; |
DanielKahr | 4:25f04078bca4 | 106 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 107 | LedD16=0; |
DanielKahr | 4:25f04078bca4 | 108 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 109 | LedD15=0; |
DanielKahr | 3:6acee5d90cd0 | 110 | |
DanielKahr | 4:25f04078bca4 | 111 | LedD14=1; |
DanielKahr | 4:25f04078bca4 | 112 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 113 | LedD13=1; |
DanielKahr | 4:25f04078bca4 | 114 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 115 | LedD14=0; |
DanielKahr | 4:25f04078bca4 | 116 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 117 | LedD13=0; |
DanielKahr | 4:25f04078bca4 | 118 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 119 | |
DanielKahr | 4:25f04078bca4 | 120 | LedD4=1; |
DanielKahr | 4:25f04078bca4 | 121 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 122 | LedD3=1; |
DanielKahr | 4:25f04078bca4 | 123 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 124 | LedD4=0; |
DanielKahr | 4:25f04078bca4 | 125 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 126 | LedD3=0; |
DanielKahr | 4:25f04078bca4 | 127 | wait (0.1); |
Enenkel | 0:fe5e1c689c26 | 128 | |
DanielKahr | 4:25f04078bca4 | 129 | LedD2=1; |
DanielKahr | 4:25f04078bca4 | 130 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 131 | LedD1=1; |
DanielKahr | 4:25f04078bca4 | 132 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 133 | LedD2=0; |
DanielKahr | 4:25f04078bca4 | 134 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 135 | LedD1=0; |
DanielKahr | 4:25f04078bca4 | 136 | wait (0.1); |
DanielKahr | 4:25f04078bca4 | 137 | |
Enenkel | 0:fe5e1c689c26 | 138 | } |
Enenkel | 0:fe5e1c689c26 | 139 | } |
Enenkel | 0:fe5e1c689c26 | 140 | // ENDE ***************************************************** |
Enenkel | 2:46da9f6bc48c | 141 | /* ++++++++++ ÜBUNGEN ++++++++++++ |
Enenkel | 2:46da9f6bc48c | 142 | Erstelle eine Software, welche im 0.5 Sec Takt |
Enenkel | 2:46da9f6bc48c | 143 | die in der jeweiligen Var. angegebenen Sequenzen abarbeitet. |
Enenkel | 2:46da9f6bc48c | 144 | x = LED ON |
Enenkel | 2:46da9f6bc48c | 145 | Var.1 Var.2 |
Enenkel | 2:46da9f6bc48c | 146 | 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 |
Enenkel | 2:46da9f6bc48c | 147 | D1 x x x - - - - - - - - x - - - - - - - x x x - x |
Enenkel | 2:46da9f6bc48c | 148 | D2 - x x x - - - - - - - x - - - - - - x x x - - x |
Enenkel | 2:46da9f6bc48c | 149 | D3 - - x x x - - - - - - x - - - - - x x x - - - x |
Enenkel | 2:46da9f6bc48c | 150 | D4 - - - x x x - - - - - x - - - - x x x - - - - x |
Enenkel | 2:46da9f6bc48c | 151 | D13 - - - - x x x - - - - x - - - x x x - - - - - x |
Enenkel | 2:46da9f6bc48c | 152 | D14 - - - - - x x x - - - x - - x x x - - - - - - x |
Enenkel | 2:46da9f6bc48c | 153 | D15 - - - - - - x x x - - x - x x x - - - - - - - x |
Enenkel | 2:46da9f6bc48c | 154 | D16 - - - - - - - x x x - x x x x - - - - - - - - x |
Enenkel | 0:fe5e1c689c26 | 155 | |
Enenkel | 2:46da9f6bc48c | 156 | Var.3 Var.4 |
Enenkel | 2:46da9f6bc48c | 157 | 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 |
Enenkel | 2:46da9f6bc48c | 158 | D1 x x x x - - - - - - - - - - - - - - - x x x x - |
Enenkel | 2:46da9f6bc48c | 159 | D2 - x x x x - - - - - - - - - - - - - x x x x - - |
Enenkel | 2:46da9f6bc48c | 160 | D3 - - x x x x - - - - - - - - - - - x x x x - - - |
Enenkel | 2:46da9f6bc48c | 161 | D4 - - - x x x x - - - - - - - - - x x x x - - - - |
Enenkel | 2:46da9f6bc48c | 162 | D13 - - - x x x x x - - - - - - - x x x x - - - - - |
Enenkel | 2:46da9f6bc48c | 163 | D14 - - - - x x x x x - - - - - x x x x - - - - - - |
Enenkel | 2:46da9f6bc48c | 164 | D15 - - - - - x x x x x - - - x x x x - - - - - - - |
Enenkel | 2:46da9f6bc48c | 165 | D16 - - - - - - x x x x x - x x x x - - - - - - - - |
Enenkel | 2:46da9f6bc48c | 166 | |
Enenkel | 2:46da9f6bc48c | 167 | Var.5 Var.6 |
Enenkel | 2:46da9f6bc48c | 168 | 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 |
Enenkel | 2:46da9f6bc48c | 169 | D1 x x x - - - - - - - x x x - - - - - - - - - - - |
Enenkel | 2:46da9f6bc48c | 170 | D2 - x x x - - - - - x x - - x - - - - - - - - - - |
Enenkel | 2:46da9f6bc48c | 171 | D3 - - x x x - - - x x - - - - x - - - - - - - - - |
Enenkel | 2:46da9f6bc48c | 172 | D4 - - - x x x - x x - - - - - - x - - - - - - - x |
Enenkel | 2:46da9f6bc48c | 173 | D13 - - - x x x - x x - - - - - - - x - - - - - x - |
Enenkel | 2:46da9f6bc48c | 174 | D14 - - x x x - - - x x - - - - - - - x - - - x - - |
Enenkel | 2:46da9f6bc48c | 175 | D15 - x x x - - - - - x x - - - - - - - x - x - - - |
Enenkel | 2:46da9f6bc48c | 176 | D16 x x x - - - - - - - x x - - - - - - - x - - - - |
Enenkel | 2:46da9f6bc48c | 177 | |
Enenkel | 2:46da9f6bc48c | 178 | |
Enenkel | 2:46da9f6bc48c | 179 | Var.7 Var.8 |
Enenkel | 2:46da9f6bc48c | 180 | 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 |
Enenkel | 2:46da9f6bc48c | 181 | D1 x - - - - - x - - - x - - - - x - x - x - - - x |
Enenkel | 2:46da9f6bc48c | 182 | D2 x - - - - - x - - - x - - - - x - x - x - - - x |
Enenkel | 2:46da9f6bc48c | 183 | D3 - x - - - x - x - - x - - - x - - x - - x - - x |
Enenkel | 2:46da9f6bc48c | 184 | D4 - x - - - x - x - - x - - - x - - x - - x - - x |
Enenkel | 2:46da9f6bc48c | 185 | D13 - - x - x - - - x - x - - x - - - x - - - x - x |
Enenkel | 2:46da9f6bc48c | 186 | D14 - - x - x - - - x - x - - x - - - x - - - x - - x |
Enenkel | 2:46da9f6bc48c | 187 | D15 - - - x - - - - - x x - x - - - - x - - - - x - x |
Enenkel | 2:46da9f6bc48c | 188 | D16 - - - x - - - - - x x - x - - - - x - - - - x - x |
Enenkel | 2:46da9f6bc48c | 189 | |
Enenkel | 2:46da9f6bc48c | 190 | ********************** ENDE ***********************************/ |