Mesud Klisura Selma Tucak

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tim003
Date:
Thu Apr 10 17:59:31 2014 +0000
Commit message:
LV6_Zadatak1_Tim003_Grupa7

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f50fdb0b4c15 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 10 17:59:31 2014 +0000
@@ -0,0 +1,77 @@
+#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) {}
+    
+}
diff -r 000000000000 -r f50fdb0b4c15 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Apr 10 17:59:31 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file