Benjamin Hrustemović Benjamin Ramić

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
2016US_BenjaminRamic
Date:
Mon Mar 14 20:13:04 2016 +0000
Commit message:
LV2_US_Grupa8_Tim8

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 d063a3cae27e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 14 20:13:04 2016 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+#define dp23 P0_0
+
+DigitalIn taster1(dp1);
+DigitalIn taster2(dp2);
+
+BusOut lediceDisplej (dp26, dp27, dp5, dp6, dp28, dp4, dp18);
+int izlazi[] = {121, 36, 48, 25, 18, 2, 120, 0, 16, 64};
+BusOut ukljuci(dp23, dp24, dp25);
+
+int taster1Prethodno = 0; 
+int taster2Prethodno = 0; 
+int broj = 0;
+DigitalOut enable(dp14);
+
+void prikazi(int segment, int cifra)
+{
+    if (segment==1) ukljuci=6;
+    if (segment==2) ukljuci=5;
+    if (segment==3) ukljuci=3;
+    //ukljuci = segment;
+    lediceDisplej = cifra;
+}
+
+void ocitaj()
+{
+    if (taster1Prethodno == 0 && taster1 == 1)
+    {
+        broj++;
+        if(broj > 999)
+            broj = 0;   
+    }else if(taster2Prethodno == 0 && taster2 == 1)
+    {
+        broj--;
+        if(broj < 0)
+        broj = 999;
+    }
+    
+    taster1Prethodno = taster1;
+    taster2Prethodno = taster2;
+}
+
+
+void osvjezi()
+{
+    int i = 3;
+    int privremeni = broj;
+    do
+    {
+        int cifra = privremeni%10;
+        privremeni/=10;
+        prikazi(i, cifra);
+        i--;
+        wait(0.2);
+    }while(privremeni > 0);
+}
+int main() {
+    enable = 1;
+    
+    lediceDisplej = 25;
+    wait(1);
+    lediceDisplej = 0;
+    wait(1);
+    lediceDisplej = 25;
+    wait(1);
+    lediceDisplej = 0;
+    wait(1);
+    lediceDisplej = 25;
+    wait(1);
+    lediceDisplej = 0;
+    wait(1);
+    lediceDisplej = 25;
+    
+    while(1)
+    {
+        ocitaj();
+        wait(2);
+        osvjezi();
+    }
+    
+    
+}
diff -r 000000000000 -r d063a3cae27e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 14 20:13:04 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file