02c
Dependencies: mbed
Fork of M0_Lektion02c by
main.cpp@2:4d97fbc35b11, 2016-01-06 (annotated)
- Committer:
- Enenkel
- Date:
- Wed Jan 06 13:32:24 2016 +0000
- Revision:
- 2:4d97fbc35b11
- Parent:
- 1:09e5e84d0b38
- Child:
- 3:80b8ddc2f3ad
Lauflicht ?ber 8 LED mit 2 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 | 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 |
Enenkel | 0:2d0317d249dc | 25 | wait (0.2); |
Enenkel | 0:2d0317d249dc | 26 | led=0x2; //LED 0011 ->Hex 2 |
Enenkel | 2:4d97fbc35b11 | 27 | // Ergänze selber in HEX! |
Enenkel | 0:2d0317d249dc | 28 | |
Enenkel | 0:2d0317d249dc | 29 | wait (0.2); |
Enenkel | 0:2d0317d249dc | 30 | led=0xF; //LED 1111 |
Enenkel | 2:4d97fbc35b11 | 31 | //LED 0000 |
Enenkel | 2:4d97fbc35b11 | 32 | //LED 1000 |
Enenkel | 2:4d97fbc35b11 | 33 | // nun läuft der Balken wieder zurück! |
Enenkel | 0:2d0317d249dc | 34 | } |
Enenkel | 0:2d0317d249dc | 35 | } |
Enenkel | 2:4d97fbc35b11 | 36 | // ***************** ENDE *********************************** |
Enenkel | 0:2d0317d249dc | 37 |