Hasanić Nadin Odobašić Faris

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tim004
Date:
Mon Mar 17 10:56:30 2014 +0000
Commit message:
LV2-Pai-Grupa2_tim004-zad2

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 cdcd284f12e2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 17 10:56:30 2014 +0000
@@ -0,0 +1,104 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+ int numbersArray [16] = {0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10, 0x08, 0x03, 0x46, 0x21, 0x09, 0x37};
+ BusOut lediceSegment (dp26, dp27, dp5, dp6, dp28, dp1, dp2);
+ BusOut point (dp4);
+ BusOut digitPin (dp23, dp24, dp25);
+ DigitalOut redovi [4] = {dp16, dp15, dp17, dp18};
+ DigitalIn kolone [4] = {dp9, dp10, dp11, dp13};
+
+bool JelPritisnuto (DigitalIn in)
+{
+    if(!in)
+        return false;
+    int br = 0;
+    for (int i = 0; i < 200; i++)
+        if(in) br++;
+    if(br >= 120) 
+        return true;
+    return false;
+}
+
+int VratiZnak ()
+{
+        int a=18;
+        redovi[0] = 1;
+    if(kolone[0] == 1) a= 1;
+    if(kolone[1] == 1) a= 2;
+    if(kolone[2] == 1) a= 3;
+    if(kolone[3] == 1) a= 10;
+    redovi[0] = 0;
+    
+    
+    redovi[1] = 1;
+    if(kolone[0] == 1) a= 4;
+    if(kolone[1] == 1) a= 5;
+    if(kolone[2] == 1) a= 6;
+    if(kolone[3] == 1) a= 11;
+    redovi[1] = 0;
+    
+    redovi[2] = 1;
+    if(kolone[0] == 1) a= 7;
+    if(kolone[1] == 1) a= 8;
+    if(kolone[2] == 1) a= 9;
+    if(kolone[3] == 1) a= 12;
+    redovi[2] = 0;
+    
+    redovi[3] = 1;
+    if(kolone[0] == 1) a=  15;
+    if(kolone[1] == 1) a=  0;
+    if(kolone[2] == 1) a=  14;
+    if(kolone[3] == 1) a=  13;
+    redovi[3] = 0;
+    if(a!= 18){
+                return a;
+        }
+    
+    return 20;
+}
+
+void Ispis (int znak)
+{
+    
+    if(znak != 12 && znak != 20)
+        lediceSegment = numbersArray[znak];
+        
+    else if (znak == 12)
+    {
+        int  br = 0;
+        while (br < 3)
+        {
+            if (br == 0)
+                digitPin = 3;
+            else if (br == 1)
+                digitPin = 5;
+            else if (br == 2)
+                digitPin = 6;
+            lediceSegment = 0x40;
+            wait_ms(10);
+            br++;
+        }
+    }
+        
+    
+        
+}
+
+int main() {
+   int broj = 0;
+   while (1)
+   {
+        while (broj == 0)
+       {
+            if(VratiZnak() != 20)
+                broj = 1;
+            else
+                wait_ms(0.1);
+        }
+        Ispis(VratiZnak()); wait_ms(10);
+        broj = 0;
+    }
+  
+}
diff -r 000000000000 -r cdcd284f12e2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 17 10:56:30 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1
\ No newline at end of file