Leonard Haghofer
/
M0_Lektion02c
02c
Fork of M0_Lektion02c by
main.cpp@1:09e5e84d0b38, 2015-03-06 (annotated)
- Committer:
- Enenkel
- Date:
- Fri Mar 06 07:58:34 2015 +0000
- Revision:
- 1:09e5e84d0b38
- Parent:
- 0:2d0317d249dc
- Child:
- 2:4d97fbc35b11
Lauflicht ?ber 4 Led mit 1 Led via Bus
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:2d0317d249dc | 1 | #include "mbed.h" |
Enenkel | 1:09e5e84d0b38 | 2 | // HIMBED Lektion_02c "Lauflicht 4LED via BUS" |
Enenkel | 0:2d0317d249dc | 3 | // by Gottfried ENENKEL 2014-12-12 |
Enenkel | 0:2d0317d249dc | 4 | // AUFGABE: |
Enenkel | 0:2d0317d249dc | 5 | // Die LED D1 bis D4 werden als BUS definiert. |
Enenkel | 0:2d0317d249dc | 6 | // 4 Leitungen -> 16 Möglichkeiten-> 0-F |
Enenkel | 0:2d0317d249dc | 7 | // EIN LED soll hin und her laufen |
Enenkel | 0:2d0317d249dc | 8 | // Am Anfang und am Ende darf kein LED leuchten ! |
Enenkel | 0:2d0317d249dc | 9 | // |
Enenkel | 0:2d0317d249dc | 10 | // DEFINITIONEN ************************************************* |
Enenkel | 0:2d0317d249dc | 11 | // Bus Definition |
Enenkel | 0:2d0317d249dc | 12 | BusOut led(P1_8,P1_9,P1_10,P1_11); |
Enenkel | 0:2d0317d249dc | 13 | // LSB MSB |
Enenkel | 0:2d0317d249dc | 14 | |
Enenkel | 0:2d0317d249dc | 15 | // HAUPTPROGRAMM *********************************************** |
Enenkel | 0:2d0317d249dc | 16 | int main() { |
Enenkel | 0:2d0317d249dc | 17 | led=0xF; // Alle 4 LED EIN |
Enenkel | 0:2d0317d249dc | 18 | wait(1); // warte 1 sec. |
Enenkel | 0:2d0317d249dc | 19 | while(1) // Hauptschleife |
Enenkel | 0:2d0317d249dc | 20 | { |
Enenkel | 0:2d0317d249dc | 21 | led=0x0; //LED 0000 Hex 0 |
Enenkel | 0:2d0317d249dc | 22 | wait(0.2); |
Enenkel | 0:2d0317d249dc | 23 | led=0x1; //LED 0001 Hex 1 |
Enenkel | 0:2d0317d249dc | 24 | wait (0.2); |
Enenkel | 0:2d0317d249dc | 25 | led=0x2; //LED 0011 ->Hex 2 |
Enenkel | 0:2d0317d249dc | 26 | // Ergänze selber in HEX! |
Enenkel | 0:2d0317d249dc | 27 | |
Enenkel | 0:2d0317d249dc | 28 | wait (0.2); |
Enenkel | 0:2d0317d249dc | 29 | led=0xF; //LED 1111 |
Enenkel | 0:2d0317d249dc | 30 | //LED 0000 |
Enenkel | 0:2d0317d249dc | 31 | //LED 1000 |
Enenkel | 0:2d0317d249dc | 32 | // nun läuft der Balken wieder zurück! |
Enenkel | 0:2d0317d249dc | 33 | |
Enenkel | 0:2d0317d249dc | 34 | |
Enenkel | 0:2d0317d249dc | 35 | } |
Enenkel | 0:2d0317d249dc | 36 | } |
Enenkel | 0:2d0317d249dc | 37 | // ENDE ***************************************************** |
Enenkel | 0:2d0317d249dc | 38 |