TEST Note 2
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:74a586aeaa55
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 23 17:50:55 2015 +0000 @@ -0,0 +1,86 @@ +#include "mbed.h" + +BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); +DigitalIn Sw1 (P0_10); +DigitalIn Sw2 (P0_15); + +void RunLigthLeft(); +void RunLigthRight(); +void Blinker(); + +int main() +{ + while(1) + { + if(Sw1==1) + { + RunLigthLeft(); + } + + if(Sw2==1) + { + RunLigthRight(); + } + + if (Sw1==1 && Sw2 ==1) + { + Blinker(); + } +} + +} +void RunLigthLeft() +{ + int i; + lb=1; + wait_ms(200); + for (i=1;i<=2;i++) + { + lb=lb<<1; + lb=lb|1; + wait_ms(200); + } + + + for(i=1;i<=11;i++) + { + lb=lb <<1; + wait_ms(200); + } +} + +void RunLigthRight() +{ + int i; + lb=2048; + wait_ms(200); + for (i=1;i<=2;i++) + { + lb=lb>>1; + lb=lb|1; + wait_ms(200); + + } + + for(i=1;i<=11;i++) + { + lb=lb >>1; + wait_ms(200); + } + + } + + +void Blinker() +{ int i=0; +for(i=0; i<10; i++) +{ +lb = 0x2AAAA; wait_ms(200); +lb = lb <<1; lb=lb|1; +wait_ms(200); +} + +} + + + \ No newline at end of file