tim008 tim008
/
LV2_Grupa5_TIM008-zadatak2
Emir Mujačić Amela Špica
Diff: main.cpp
- Revision:
- 0:8a8efa06ba06
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 13 14:13:07 2014 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" + +BusOut led(dp23, dp24, dp25, dp26, dp27, dp5, dp6, dp28); +DigitalOut enabled(dp14); +DigitalIn taster1(dp1); +DigitalIn taster2(dp2); + +int main() { + int p1 = 0, p2 =0; + int brojac = 0, a = 0; + enabled=0; + led = brojac; + while(1) { + + if (p1==1) + { + a++; + if (taster1 == 1 && a > 1000) + { + brojac++; + + a = 0; + } + } + if (p2==1) + { + a++; + if (taster2 == 1 && a > 1000) + {brojac--; a = 0;} + } + if(taster1 == 0) p1=1; + else p1=0; + if(taster2 == 0) p2=1; + else p2=0; + if (brojac < 0) brojac = 255; + if (brojac > 255) brojac = 0; + led= brojac; + + } +}