tim003 tim003
/
tim7_lv6
Mesud Klisura Selma Tucak
main.cpp
- Committer:
- tim003
- Date:
- 2014-04-10
- Revision:
- 0:f50fdb0b4c15
File content as of revision 0:f50fdb0b4c15:
#include "mbed.h" BusOut segmenti (dp18, dp4, dp28, dp6, dp5, dp27, dp26); BusOut cifre (dp23, dp24, dp25); DigitalOut tacka(dp17); InterruptIn taster1 (dp1); InterruptIn taster2(dp2); int brojevi[10]={0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x00, 0x04}; Timer brojac,db1,db2; int cifra1,cifra2,cifra3; Ticker t1,t2,t3; bool start(true); void trecaCifra(){ __disable_irq(); cifra3=(int((brojac.read()/10))%10); //cifra3=8; cifre=6; segmenti=brojevi[cifra3]; tacka=1; __enable_irq(); } void drugaCifra() { __disable_irq(); tacka=0; cifra2=int(brojac.read())%10; //cifra2=8; cifre=5; segmenti=brojevi[cifra2]; // tacka=1; __enable_irq(); } void prvaCifra() { __disable_irq(); cifra1=(int((brojac.read()*10))%10); //cifra1=8; cifre=3; segmenti=brojevi[cifra1]; tacka=1; __enable_irq(); } void pokretanje() { if (db1.read_ms()>200) { if(start) brojac.start(); else brojac.stop(); start=!start; db1.reset(); }} void resetovanje() { if (db2.read_ms()>200) { start=true; brojac.stop(); brojac.reset(); db2.reset(); } } int main() { db1.start(); db2.start(); brojac.reset(); t1.attach(&trecaCifra, 0.001); t2.attach(&drugaCifra, 0.002); t3.attach(&prvaCifra, 0.003); taster1.rise(&pokretanje); taster2.rise(&resetovanje); while (1) {} }