tim003 tim003
/
Lab04_Zadatak01_Tim003
Ahmed Đuherić
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 BusOut displej(dp26, dp27, dp5, dp6, dp28, dp1, dp2); 00004 DigitalOut tacka(dp4); 00005 00006 int brojevi[10]={0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10}; 00007 00008 BusOut cifre(dp23, dp24, dp25); 00009 00010 AnalogIn input(dp9); 00011 00012 00013 00014 void ocitaj (float vrijednost) 00015 { 00016 00017 int znamenke[3]; 00018 vrijednost=vrijednost*10; 00019 00020 int v = (int)vrijednost; 00021 00022 znamenke[2]=v%10; 00023 v=v/10; 00024 00025 znamenke[1]=v%10; 00026 v=v/10; 00027 00028 znamenke[0]=v%10; 00029 00030 00031 cifre=6; 00032 displej=brojevi[znamenke[0]]; 00033 tacka=0; 00034 wait_ms(1); 00035 00036 00037 cifre=5; 00038 displej=brojevi[znamenke[1]]; 00039 tacka=1; 00040 wait_ms(1); 00041 00042 cifre=3; 00043 displej=brojevi[znamenke[2]]; 00044 tacka=1; 00045 wait_ms(1); 00046 } 00047 00048 00049 00050 00051 int main() { 00052 while(1) { 00053 00054 float suma=0; 00055 00056 for(int i=1;i<=1000;i++) 00057 { 00058 suma=suma+(input*33); 00059 if(i%100==0) ocitaj(suma/100); 00060 suma=0; 00061 00062 } 00063 } 00064 }
Generated on Sun Aug 7 2022 14:14:05 by 1.7.2