Mesud Klisura Selma Tucak
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 BusOut segmenti (dp18, dp4, dp28, dp6, dp5, dp27, dp26); 00004 BusOut cifre (dp23, dp24, dp25); 00005 DigitalOut tacka(dp17); 00006 InterruptIn taster1 (dp1); 00007 InterruptIn taster2(dp2); 00008 00009 int brojevi[10]={0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x00, 0x04}; 00010 Timer brojac,db1,db2; 00011 int cifra1,cifra2,cifra3; 00012 Ticker t1,t2,t3; 00013 bool start(true); 00014 00015 void trecaCifra(){ 00016 __disable_irq(); 00017 cifra3=(int((brojac.read()/10))%10); 00018 //cifra3=8; 00019 cifre=6; 00020 segmenti=brojevi[cifra3]; 00021 tacka=1; 00022 __enable_irq(); 00023 } 00024 00025 void drugaCifra() { 00026 __disable_irq(); 00027 tacka=0; 00028 cifra2=int(brojac.read())%10; 00029 //cifra2=8; 00030 cifre=5; 00031 segmenti=brojevi[cifra2]; 00032 // tacka=1; 00033 __enable_irq(); 00034 } 00035 00036 00037 void prvaCifra() { 00038 __disable_irq(); 00039 cifra1=(int((brojac.read()*10))%10); 00040 //cifra1=8; 00041 cifre=3; 00042 segmenti=brojevi[cifra1]; 00043 tacka=1; 00044 __enable_irq(); 00045 } 00046 00047 void pokretanje() { 00048 if (db1.read_ms()>200) { 00049 if(start) brojac.start(); 00050 else brojac.stop(); 00051 start=!start; 00052 db1.reset(); 00053 }} 00054 00055 void resetovanje() { 00056 if (db2.read_ms()>200) { 00057 start=true; 00058 brojac.stop(); 00059 brojac.reset(); 00060 db2.reset(); 00061 00062 } 00063 00064 } 00065 00066 int main() { 00067 db1.start(); 00068 db2.start(); 00069 brojac.reset(); 00070 t1.attach(&trecaCifra, 0.001); 00071 t2.attach(&drugaCifra, 0.002); 00072 t3.attach(&prvaCifra, 0.003); 00073 taster1.rise(&pokretanje); 00074 taster2.rise(&resetovanje); 00075 while (1) {} 00076 00077 }
Generated on Wed Jul 27 2022 04:07:16 by
1.7.2