tim008 tim008
/
lv4_Grupa5_Tim008_Zadatak2
Ilvana Brankovic Emir Mujacic
Diff: main.cpp
- Revision:
- 0:0fec84e74f19
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 27 14:18:59 2014 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" + +BusOut ledice(dp2,dp1,dp28,dp6,dp5,dp27,dp26); +BusOut cifre(dp25,dp24,dp23); +int niz[10]={0x01,0x4F,0x12,0x06,0x4C,0x24,0x20,0x0f,0x00,0x04}; +AnalogIn naponcic(dp9); +DigitalOut tacka(dp4); + +int DajSvjetlost(float napon) +{ + float svjetlost=-37.4*napon+106.74; + return int(svjetlost); +} +void funkcija(int svjetlost) +{ + int brojevi[3]={(svjetlost)%10,(svjetlost/10)%10,(svjetlost/100)%10}; + + //int brojevi[3]={1,2,3}; + cifre=3; + ledice=niz[brojevi[2]]; + wait_ms(1); + cifre=7; + + cifre=5; + ledice=niz[brojevi[1]]; + wait_ms(1); + cifre=7; + + cifre=6; + ledice=niz[brojevi[0]]; + wait_ms(1); + cifre=7; +} +int main() { + float nizf[100]; + float srednja=0.0; + int svjetlost=0; + while(1) { + + for(int i=0; i<100; i++) nizf[i]=naponcic; + for(int i=0; i<100; i++) + { srednja+=nizf[i]; funkcija(svjetlost); } + srednja=srednja/100; + svjetlost=DajSvjetlost(srednja*3.3); + funkcija(svjetlost); + + } +} \ No newline at end of file