B17_L03
Dependencies: mbed
main.cpp@0:31ed6c27ffbc, 2017-05-02 (annotated)
- Committer:
- Leonard_Haghofer
- Date:
- Tue May 02 08:57:59 2017 +0000
- Revision:
- 0:31ed6c27ffbc
B17_L03
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Leonard_Haghofer | 0:31ed6c27ffbc | 1 | #include "mbed.h" |
Leonard_Haghofer | 0:31ed6c27ffbc | 2 | /* |
Leonard_Haghofer | 0:31ed6c27ffbc | 3 | ~Lektion 03 - Bertl 2017 |
Leonard_Haghofer | 0:31ed6c27ffbc | 4 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 5 | Lauflicht mit Bus |
Leonard_Haghofer | 0:31ed6c27ffbc | 6 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 7 | BusOut led(*,*,*,*); -> Bus mit 4 LED-Pins definieren. |
Leonard_Haghofer | 0:31ed6c27ffbc | 8 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 9 | int main() |
Leonard_Haghofer | 0:31ed6c27ffbc | 10 | { |
Leonard_Haghofer | 0:31ed6c27ffbc | 11 | while(1) |
Leonard_Haghofer | 0:31ed6c27ffbc | 12 | { |
Leonard_Haghofer | 0:31ed6c27ffbc | 13 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 14 | led = led | 1; -> 1. Bit setzten. |
Leonard_Haghofer | 0:31ed6c27ffbc | 15 | led = ~led; -> LED invertieren wegen invertierten Bits. |
Leonard_Haghofer | 0:31ed6c27ffbc | 16 | wait(1.0); |
Leonard_Haghofer | 0:31ed6c27ffbc | 17 | led = 1; |
Leonard_Haghofer | 0:31ed6c27ffbc | 18 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 19 | led = led | 2; -> 2. Bit setzten. |
Leonard_Haghofer | 0:31ed6c27ffbc | 20 | led = ~led; |
Leonard_Haghofer | 0:31ed6c27ffbc | 21 | wait(1.0); |
Leonard_Haghofer | 0:31ed6c27ffbc | 22 | led = 1; |
Leonard_Haghofer | 0:31ed6c27ffbc | 23 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 24 | led = led | 4; -> 3. Bit setzten. |
Leonard_Haghofer | 0:31ed6c27ffbc | 25 | led = ~led; |
Leonard_Haghofer | 0:31ed6c27ffbc | 26 | wait(1.0); |
Leonard_Haghofer | 0:31ed6c27ffbc | 27 | led = 1; |
Leonard_Haghofer | 0:31ed6c27ffbc | 28 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 29 | led = led | 8; -> 4. Bit setzten. |
Leonard_Haghofer | 0:31ed6c27ffbc | 30 | led = ~led; |
Leonard_Haghofer | 0:31ed6c27ffbc | 31 | wait(1.0); |
Leonard_Haghofer | 0:31ed6c27ffbc | 32 | led = 1; |
Leonard_Haghofer | 0:31ed6c27ffbc | 33 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 34 | ------------------------ODER------------------------ |
Leonard_Haghofer | 0:31ed6c27ffbc | 35 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 36 | led = 1; -> LEDs ausschalten |
Leonard_Haghofer | 0:31ed6c27ffbc | 37 | *(int daten = 1;) -> Außerhalb der While-Schleife |
Leonard_Haghofer | 0:31ed6c27ffbc | 38 | led = ~daten; |
Leonard_Haghofer | 0:31ed6c27ffbc | 39 | daten=daten << 1; -> um 1 verschieben |
Leonard_Haghofer | 0:31ed6c27ffbc | 40 | if (daten > 8) |
Leonard_Haghofer | 0:31ed6c27ffbc | 41 | { |
Leonard_Haghofer | 0:31ed6c27ffbc | 42 | daten = 1; |
Leonard_Haghofer | 0:31ed6c27ffbc | 43 | } |
Leonard_Haghofer | 0:31ed6c27ffbc | 44 | wait(1.0); |
Leonard_Haghofer | 0:31ed6c27ffbc | 45 | |
Leonard_Haghofer | 0:31ed6c27ffbc | 46 | } |
Leonard_Haghofer | 0:31ed6c27ffbc | 47 | } |
Leonard_Haghofer | 0:31ed6c27ffbc | 48 | */ |