Ilvana Brankovic Emir Mujacic
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 BusOut ledice(dp2,dp1,dp28,dp6,dp5,dp27,dp26); 00004 BusOut cifre(dp25,dp24,dp23); 00005 int niz[10]={0x01,0x4F,0x12,0x06,0x4C,0x24,0x20,0x0f,0x00,0x04}; 00006 AnalogIn naponcic(dp9); 00007 DigitalOut tacka(dp4); 00008 00009 int DajSvjetlost(float napon) 00010 { 00011 float svjetlost=-37.4*napon+106.74; 00012 return int(svjetlost); 00013 } 00014 void funkcija(int svjetlost) 00015 { 00016 int brojevi[3]={(svjetlost)%10,(svjetlost/10)%10,(svjetlost/100)%10}; 00017 00018 //int brojevi[3]={1,2,3}; 00019 cifre=3; 00020 ledice=niz[brojevi[2]]; 00021 wait_ms(1); 00022 cifre=7; 00023 00024 cifre=5; 00025 ledice=niz[brojevi[1]]; 00026 wait_ms(1); 00027 cifre=7; 00028 00029 cifre=6; 00030 ledice=niz[brojevi[0]]; 00031 wait_ms(1); 00032 cifre=7; 00033 } 00034 int main() { 00035 float nizf[100]; 00036 float srednja=0.0; 00037 int svjetlost=0; 00038 while(1) { 00039 00040 for(int i=0; i<100; i++) nizf[i]=naponcic; 00041 for(int i=0; i<100; i++) 00042 { srednja+=nizf[i]; funkcija(svjetlost); } 00043 srednja=srednja/100; 00044 svjetlost=DajSvjetlost(srednja*3.3); 00045 funkcija(svjetlost); 00046 00047 } 00048 }
Generated on Wed Sep 7 2022 15:17:33 by
1.7.2