02c
Dependencies: mbed
Fork of M0_Lektion02c by
main.cpp@3:80b8ddc2f3ad, 2016-01-29 (annotated)
- Committer:
- Leonard_Haghofer
- Date:
- Fri Jan 29 13:07:49 2016 +0000
- Revision:
- 3:80b8ddc2f3ad
- Parent:
- 2:4d97fbc35b11
02c
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 | 2:4d97fbc35b11 | 16 | int main() |
Enenkel | 2:4d97fbc35b11 | 17 | { |
Enenkel | 0:2d0317d249dc | 18 | led=0xF; // Alle 4 LED EIN |
Enenkel | 0:2d0317d249dc | 19 | wait(1); // warte 1 sec. |
Enenkel | 0:2d0317d249dc | 20 | while(1) // Hauptschleife |
Enenkel | 0:2d0317d249dc | 21 | { |
Enenkel | 0:2d0317d249dc | 22 | led=0x0; //LED 0000 Hex 0 |
Enenkel | 0:2d0317d249dc | 23 | wait(0.2); |
Enenkel | 0:2d0317d249dc | 24 | led=0x1; //LED 0001 Hex 1 |
Leonard_Haghofer | 3:80b8ddc2f3ad | 25 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 26 | led=0x3; //LED 0011 ->Hex 2 |
Leonard_Haghofer | 3:80b8ddc2f3ad | 27 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 28 | led=0x7; // Ergänze selber in HEX! |
Leonard_Haghofer | 3:80b8ddc2f3ad | 29 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 30 | led=0xF; |
Leonard_Haghofer | 3:80b8ddc2f3ad | 31 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 32 | led=0x7; |
Leonard_Haghofer | 3:80b8ddc2f3ad | 33 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 34 | led=0x3; |
Leonard_Haghofer | 3:80b8ddc2f3ad | 35 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 36 | led=0x1; |
Leonard_Haghofer | 3:80b8ddc2f3ad | 37 | wait(0.2); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 38 | led=0x0; |
Leonard_Haghofer | 3:80b8ddc2f3ad | 39 | wait(1.0); |
Leonard_Haghofer | 3:80b8ddc2f3ad | 40 | //LED 1111 |
Enenkel | 2:4d97fbc35b11 | 41 | //LED 0000 |
Enenkel | 2:4d97fbc35b11 | 42 | //LED 1000 |
Enenkel | 2:4d97fbc35b11 | 43 | // nun läuft der Balken wieder zurück! |
Enenkel | 0:2d0317d249dc | 44 | } |
Enenkel | 0:2d0317d249dc | 45 | } |
Enenkel | 2:4d97fbc35b11 | 46 | // ***************** ENDE *********************************** |
Enenkel | 0:2d0317d249dc | 47 |