Martin Werluschnig
/
Umschalt_Lauflicht
Umschalt_Lauflicht
main.cpp@0:26a539991e86, 2018-11-15 (annotated)
- Committer:
- martwerl
- Date:
- Thu Nov 15 18:25:45 2018 +0000
- Revision:
- 0:26a539991e86
Umschalt_Lauflicht
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
martwerl | 0:26a539991e86 | 1 | //Umschalt_Lauflicht |
martwerl | 0:26a539991e86 | 2 | #include "mbed.h" |
martwerl | 0:26a539991e86 | 3 | |
martwerl | 0:26a539991e86 | 4 | DigitalIn diUp(p15); |
martwerl | 0:26a539991e86 | 5 | DigitalIn diDown(p12); |
martwerl | 0:26a539991e86 | 6 | BusOut doLeds(LED1,LED2,LED3,LED4); |
martwerl | 0:26a539991e86 | 7 | |
martwerl | 0:26a539991e86 | 8 | int main() |
martwerl | 0:26a539991e86 | 9 | { |
martwerl | 0:26a539991e86 | 10 | doLeds = 0; |
martwerl | 0:26a539991e86 | 11 | while(1) |
martwerl | 0:26a539991e86 | 12 | { |
martwerl | 0:26a539991e86 | 13 | if (diDown) |
martwerl | 0:26a539991e86 | 14 | { |
martwerl | 0:26a539991e86 | 15 | if (doLeds <= 0) |
martwerl | 0:26a539991e86 | 16 | doLeds = 8; |
martwerl | 0:26a539991e86 | 17 | else |
martwerl | 0:26a539991e86 | 18 | doLeds = doLeds>>1; // um eine position nach rechts schieben |
martwerl | 0:26a539991e86 | 19 | } |
martwerl | 0:26a539991e86 | 20 | else if (diUp) |
martwerl | 0:26a539991e86 | 21 | { |
martwerl | 0:26a539991e86 | 22 | if (doLeds <= 0) |
martwerl | 0:26a539991e86 | 23 | doLeds = 1; |
martwerl | 0:26a539991e86 | 24 | else |
martwerl | 0:26a539991e86 | 25 | doLeds = doLeds<<1; // um eine position nach links schieben |
martwerl | 0:26a539991e86 | 26 | } |
martwerl | 0:26a539991e86 | 27 | if (doLeds != 0) |
martwerl | 0:26a539991e86 | 28 | wait(0.5); |
martwerl | 0:26a539991e86 | 29 | } |
martwerl | 0:26a539991e86 | 30 | } |