Mumin Hadzic
/
Button2_19_12_2019
Button
Diff: main.cpp
- Revision:
- 0:f38709642054
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 19 18:28:18 2019 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" + +BusOut lb(D2,D3,D6,D9,D11,D12,A6,D13); +DigitalIn T1(A1); +int CheckButton(); +void OneRunLightStepR2(); +int prevButtonState=0; +void main() + +{ + lb=1; + while(1){ + if (CheckButton()==1) + + OneRunLightStepR2(); + + } + } +int CheckButton() +{ + int ret; + if(prevButtonState== 1 && T1.read()== 0) + ret=1; + else + ret=0; + prevButtonState = T1.read(); + return ret; + } + + +void OneRunLightStepR2() + { + if (lb==0) + lb = 1; + else + lb = lb<<1; + + } +