![](/media/cache/group/Download_u2oFdPW.jpg.50x50_q85.jpg)
6.4 Wenn sich jemand nähert, Lauflicht einschalten und Akustisches Signal
Dependencies: mbed
Fork of 04-09-Uebung by
main.cpp@0:a2dc2e18687d, 2015-02-20 (annotated)
- Committer:
- stefan1691
- Date:
- Fri Feb 20 18:53:21 2015 +0000
- Revision:
- 0:a2dc2e18687d
- Child:
- 1:2315b7ecebe9
4.3 Lauflicht (for, Rechnen)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefan1691 | 0:a2dc2e18687d | 1 | /** 4.3 Lauflicht (for, Rechnen) |
stefan1691 | 0:a2dc2e18687d | 2 | */ |
stefan1691 | 0:a2dc2e18687d | 3 | #include "mbed.h" |
stefan1691 | 0:a2dc2e18687d | 4 | |
stefan1691 | 0:a2dc2e18687d | 5 | DigitalOut led1( D10 ); |
stefan1691 | 0:a2dc2e18687d | 6 | DigitalOut led2( D11 ); |
stefan1691 | 0:a2dc2e18687d | 7 | DigitalOut led3( D12 ); |
stefan1691 | 0:a2dc2e18687d | 8 | DigitalOut led4( D13 ); |
stefan1691 | 0:a2dc2e18687d | 9 | |
stefan1691 | 0:a2dc2e18687d | 10 | |
stefan1691 | 0:a2dc2e18687d | 11 | int main() |
stefan1691 | 0:a2dc2e18687d | 12 | { |
stefan1691 | 0:a2dc2e18687d | 13 | while (true) |
stefan1691 | 0:a2dc2e18687d | 14 | { |
stefan1691 | 0:a2dc2e18687d | 15 | for ( int i = 0; i < 5; i++ ) |
stefan1691 | 0:a2dc2e18687d | 16 | { |
stefan1691 | 0:a2dc2e18687d | 17 | switch ( i ) |
stefan1691 | 0:a2dc2e18687d | 18 | { |
stefan1691 | 0:a2dc2e18687d | 19 | case 0: |
stefan1691 | 0:a2dc2e18687d | 20 | led1 = led2 = led3 = led4 = 0; |
stefan1691 | 0:a2dc2e18687d | 21 | break; |
stefan1691 | 0:a2dc2e18687d | 22 | case 1: |
stefan1691 | 0:a2dc2e18687d | 23 | led1 = 1; |
stefan1691 | 0:a2dc2e18687d | 24 | break; |
stefan1691 | 0:a2dc2e18687d | 25 | case 2: |
stefan1691 | 0:a2dc2e18687d | 26 | led1 = 0; |
stefan1691 | 0:a2dc2e18687d | 27 | led2 = 1; |
stefan1691 | 0:a2dc2e18687d | 28 | break; |
stefan1691 | 0:a2dc2e18687d | 29 | case 3: |
stefan1691 | 0:a2dc2e18687d | 30 | led2 = 0; |
stefan1691 | 0:a2dc2e18687d | 31 | led3 = 1; |
stefan1691 | 0:a2dc2e18687d | 32 | break; |
stefan1691 | 0:a2dc2e18687d | 33 | case 4: |
stefan1691 | 0:a2dc2e18687d | 34 | led3 = 0; |
stefan1691 | 0:a2dc2e18687d | 35 | led4 = 1; |
stefan1691 | 0:a2dc2e18687d | 36 | break; |
stefan1691 | 0:a2dc2e18687d | 37 | } |
stefan1691 | 0:a2dc2e18687d | 38 | wait( 0.5 ); |
stefan1691 | 0:a2dc2e18687d | 39 | } |
stefan1691 | 0:a2dc2e18687d | 40 | } |
stefan1691 | 0:a2dc2e18687d | 41 | } |