TEST Note 2
Dependencies: mbed
main.cpp@0:74a586aeaa55, 2015-11-23 (annotated)
- Committer:
- schoeni_91
- Date:
- Mon Nov 23 17:50:55 2015 +0000
- Revision:
- 0:74a586aeaa55
Test Note (2)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
schoeni_91 | 0:74a586aeaa55 | 1 | #include "mbed.h" |
schoeni_91 | 0:74a586aeaa55 | 2 | |
schoeni_91 | 0:74a586aeaa55 | 3 | BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); |
schoeni_91 | 0:74a586aeaa55 | 4 | DigitalIn Sw1 (P0_10); |
schoeni_91 | 0:74a586aeaa55 | 5 | DigitalIn Sw2 (P0_15); |
schoeni_91 | 0:74a586aeaa55 | 6 | |
schoeni_91 | 0:74a586aeaa55 | 7 | void RunLigthLeft(); |
schoeni_91 | 0:74a586aeaa55 | 8 | void RunLigthRight(); |
schoeni_91 | 0:74a586aeaa55 | 9 | void Blinker(); |
schoeni_91 | 0:74a586aeaa55 | 10 | |
schoeni_91 | 0:74a586aeaa55 | 11 | int main() |
schoeni_91 | 0:74a586aeaa55 | 12 | { |
schoeni_91 | 0:74a586aeaa55 | 13 | while(1) |
schoeni_91 | 0:74a586aeaa55 | 14 | { |
schoeni_91 | 0:74a586aeaa55 | 15 | if(Sw1==1) |
schoeni_91 | 0:74a586aeaa55 | 16 | { |
schoeni_91 | 0:74a586aeaa55 | 17 | RunLigthLeft(); |
schoeni_91 | 0:74a586aeaa55 | 18 | } |
schoeni_91 | 0:74a586aeaa55 | 19 | |
schoeni_91 | 0:74a586aeaa55 | 20 | if(Sw2==1) |
schoeni_91 | 0:74a586aeaa55 | 21 | { |
schoeni_91 | 0:74a586aeaa55 | 22 | RunLigthRight(); |
schoeni_91 | 0:74a586aeaa55 | 23 | } |
schoeni_91 | 0:74a586aeaa55 | 24 | |
schoeni_91 | 0:74a586aeaa55 | 25 | if (Sw1==1 && Sw2 ==1) |
schoeni_91 | 0:74a586aeaa55 | 26 | { |
schoeni_91 | 0:74a586aeaa55 | 27 | Blinker(); |
schoeni_91 | 0:74a586aeaa55 | 28 | } |
schoeni_91 | 0:74a586aeaa55 | 29 | } |
schoeni_91 | 0:74a586aeaa55 | 30 | |
schoeni_91 | 0:74a586aeaa55 | 31 | } |
schoeni_91 | 0:74a586aeaa55 | 32 | void RunLigthLeft() |
schoeni_91 | 0:74a586aeaa55 | 33 | { |
schoeni_91 | 0:74a586aeaa55 | 34 | int i; |
schoeni_91 | 0:74a586aeaa55 | 35 | lb=1; |
schoeni_91 | 0:74a586aeaa55 | 36 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 37 | for (i=1;i<=2;i++) |
schoeni_91 | 0:74a586aeaa55 | 38 | { |
schoeni_91 | 0:74a586aeaa55 | 39 | lb=lb<<1; |
schoeni_91 | 0:74a586aeaa55 | 40 | lb=lb|1; |
schoeni_91 | 0:74a586aeaa55 | 41 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 42 | } |
schoeni_91 | 0:74a586aeaa55 | 43 | |
schoeni_91 | 0:74a586aeaa55 | 44 | |
schoeni_91 | 0:74a586aeaa55 | 45 | for(i=1;i<=11;i++) |
schoeni_91 | 0:74a586aeaa55 | 46 | { |
schoeni_91 | 0:74a586aeaa55 | 47 | lb=lb <<1; |
schoeni_91 | 0:74a586aeaa55 | 48 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 49 | } |
schoeni_91 | 0:74a586aeaa55 | 50 | } |
schoeni_91 | 0:74a586aeaa55 | 51 | |
schoeni_91 | 0:74a586aeaa55 | 52 | void RunLigthRight() |
schoeni_91 | 0:74a586aeaa55 | 53 | { |
schoeni_91 | 0:74a586aeaa55 | 54 | int i; |
schoeni_91 | 0:74a586aeaa55 | 55 | lb=2048; |
schoeni_91 | 0:74a586aeaa55 | 56 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 57 | for (i=1;i<=2;i++) |
schoeni_91 | 0:74a586aeaa55 | 58 | { |
schoeni_91 | 0:74a586aeaa55 | 59 | lb=lb>>1; |
schoeni_91 | 0:74a586aeaa55 | 60 | lb=lb|1; |
schoeni_91 | 0:74a586aeaa55 | 61 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 62 | |
schoeni_91 | 0:74a586aeaa55 | 63 | } |
schoeni_91 | 0:74a586aeaa55 | 64 | |
schoeni_91 | 0:74a586aeaa55 | 65 | for(i=1;i<=11;i++) |
schoeni_91 | 0:74a586aeaa55 | 66 | { |
schoeni_91 | 0:74a586aeaa55 | 67 | lb=lb >>1; |
schoeni_91 | 0:74a586aeaa55 | 68 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 69 | } |
schoeni_91 | 0:74a586aeaa55 | 70 | |
schoeni_91 | 0:74a586aeaa55 | 71 | } |
schoeni_91 | 0:74a586aeaa55 | 72 | |
schoeni_91 | 0:74a586aeaa55 | 73 | |
schoeni_91 | 0:74a586aeaa55 | 74 | void Blinker() |
schoeni_91 | 0:74a586aeaa55 | 75 | { int i=0; |
schoeni_91 | 0:74a586aeaa55 | 76 | for(i=0; i<10; i++) |
schoeni_91 | 0:74a586aeaa55 | 77 | { |
schoeni_91 | 0:74a586aeaa55 | 78 | lb = 0x2AAAA; wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 79 | lb = lb <<1; lb=lb|1; |
schoeni_91 | 0:74a586aeaa55 | 80 | wait_ms(200); |
schoeni_91 | 0:74a586aeaa55 | 81 | } |
schoeni_91 | 0:74a586aeaa55 | 82 | |
schoeni_91 | 0:74a586aeaa55 | 83 | } |
schoeni_91 | 0:74a586aeaa55 | 84 | |
schoeni_91 | 0:74a586aeaa55 | 85 | |
schoeni_91 | 0:74a586aeaa55 | 86 |