Button

Dependencies:   mbed

Committer:
muminhadzic
Date:
Thu Dec 19 18:28:18 2019 +0000
Revision:
0:f38709642054
..

Who changed what in which revision?

UserRevisionLine numberNew contents of line
muminhadzic 0:f38709642054 1 #include "mbed.h"
muminhadzic 0:f38709642054 2
muminhadzic 0:f38709642054 3 BusOut lb(D2,D3,D6,D9,D11,D12,A6,D13);
muminhadzic 0:f38709642054 4 DigitalIn T1(A1);
muminhadzic 0:f38709642054 5 int CheckButton();
muminhadzic 0:f38709642054 6 void OneRunLightStepR2();
muminhadzic 0:f38709642054 7 int prevButtonState=0;
muminhadzic 0:f38709642054 8 void main()
muminhadzic 0:f38709642054 9
muminhadzic 0:f38709642054 10 {
muminhadzic 0:f38709642054 11 lb=1;
muminhadzic 0:f38709642054 12 while(1){
muminhadzic 0:f38709642054 13 if (CheckButton()==1)
muminhadzic 0:f38709642054 14
muminhadzic 0:f38709642054 15 OneRunLightStepR2();
muminhadzic 0:f38709642054 16
muminhadzic 0:f38709642054 17 }
muminhadzic 0:f38709642054 18 }
muminhadzic 0:f38709642054 19 int CheckButton()
muminhadzic 0:f38709642054 20 {
muminhadzic 0:f38709642054 21 int ret;
muminhadzic 0:f38709642054 22 if(prevButtonState== 1 && T1.read()== 0)
muminhadzic 0:f38709642054 23 ret=1;
muminhadzic 0:f38709642054 24 else
muminhadzic 0:f38709642054 25 ret=0;
muminhadzic 0:f38709642054 26 prevButtonState = T1.read();
muminhadzic 0:f38709642054 27 return ret;
muminhadzic 0:f38709642054 28 }
muminhadzic 0:f38709642054 29
muminhadzic 0:f38709642054 30
muminhadzic 0:f38709642054 31 void OneRunLightStepR2()
muminhadzic 0:f38709642054 32 {
muminhadzic 0:f38709642054 33 if (lb==0)
muminhadzic 0:f38709642054 34 lb = 1;
muminhadzic 0:f38709642054 35 else
muminhadzic 0:f38709642054 36 lb = lb<<1;
muminhadzic 0:f38709642054 37
muminhadzic 0:f38709642054 38 }
muminhadzic 0:f38709642054 39