Dobrica Stosic 2019/277

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dobrica
Date:
Sat Nov 06 09:18:03 2021 +0000
Commit message:
Dobrica Stosic 2019/277

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 00abf8e22730 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 06 09:18:03 2021 +0000
@@ -0,0 +1,74 @@
+//biblioteke
+#include<stdio.h>
+#include "mbed.h"
+
+//direktive
+
+//glavne promenljive
+DigitalOut SEL1(PC_7);
+DigitalOut SEL2(PB_6);
+BusOut display(PA_10, PA_9, PA_8, PB_10, PB_5, PB_4, PB_3, PA_5);
+DigitalIn btn1(PC_8);
+DigitalIn btn2(PC_9);
+int num[10] = { 0b01000000, //0
+                0b01111001, //1
+                0b00100100, //2
+                0b00110000, //3
+                0b00011001, //4
+                0b00010010, //5
+                0b00000010, //6
+                0b01111000, //7
+                0b00000000, //8
+                0b00010000}; //9
+
+//glavne funkcije
+int main()
+{
+    int temp = 0, activebtn1 = 0, activebtn2 = 0;
+    
+    while(true)
+    {
+        if(!btn1 && !activebtn1)
+        {
+            activebtn1 = 1;
+            temp++;
+        }
+        else
+        {
+            activebtn1 = 0;   
+        }
+        /*if(!btn2 && !activebtn2) // DEKREMENT
+        {
+            activebtn2 = 1;
+            temp--;
+        }
+        else
+        {
+             activebtn2 = 0;   
+        }*/
+        
+        temp%=15;
+        if(temp<10)
+        {
+            SEL2 = 1;
+            SEL1 = 0;
+            display.write(num[temp]);
+            wait_ms(50);
+        }
+        else
+        {
+              SEL1 = 1;
+              SEL2 = 0;
+              display.write(num[1]);
+              
+              wait_ms(50);
+              
+              SEL2 = 1;
+              SEL1 = 0;
+              display.write(num[temp%10]);
+        }
+        wait_ms(100);
+    }   
+}
+
+//korisnicke funkcije
\ No newline at end of file
diff -r 000000000000 -r 00abf8e22730 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 06 09:18:03 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file