Display of numbers from 0 to 15

Dependencies:   mbed

Revision:
0:db2651e1ebc7
diff -r 000000000000 -r db2651e1ebc7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 06 09:22:30 2021 +0000
@@ -0,0 +1,147 @@
+
+// uvoz biblioteka 
+
+#include "mbed.h"
+
+
+// definisanje direktiva 
+
+
+#define PERIOD 50
+
+
+//glavne promenljive
+
+
+BusOut  cifra(PA_10,PA_9,PA_8,PB_10,PB_5,PB_4,PB_3);
+
+DigitalOut SEL1(PB_6);
+DigitalOut SEL2(PC_7);
+
+DigitalIn  SW1(PC_9);
+
+int jedinica[16];
+int desetica[16];
+
+
+
+
+
+
+
+// glavna funckija
+
+
+
+int main()
+{
+    
+    
+    
+jedinica[0]=0x40;   //jedinica [0] = 64;
+desetica[0]=0x7f;
+
+jedinica[1]=0x79;
+desetica[1]=0x7f;
+
+jedinica[2]=0x24;
+desetica[2]=0x7f;
+
+jedinica[3]=0x30;
+desetica[3]=0x7f;
+
+jedinica[4]=0x19;
+desetica[4]=0x7f;
+
+jedinica[5]=0x12;
+desetica[5]=0x7f;
+
+jedinica[6]=0x02;
+desetica[6]=0x7f;
+
+jedinica[7]=0x78;
+desetica[7]=0x7f;
+
+jedinica[8]=0x00;
+desetica[8]=0x7f;
+
+jedinica[9]=0x10;
+desetica[9]=0x7f;
+
+//dvocifren
+
+
+
+jedinica[10]=0x40;
+desetica[10]=0x79;
+
+jedinica[11]=0x79;
+desetica[11]=0x79;
+
+jedinica[12]=0x24;
+desetica[12]=0x79;
+
+jedinica[13]=0x30;
+desetica[13]=0x79;
+
+jedinica[14]=0x19;
+desetica[14]=0x79;
+
+jedinica[15]=0x12;
+desetica[15]=0x79;
+
+    int i;
+ //   int nijebio=1;
+    
+ //   0111111
+ //   1000000
+  //  0X3f   0x40
+  
+  cifra=0x40;
+  SEL2=0;
+  SEL1=1;
+  
+  wait(2);
+  
+ /* cifra=0x79;
+  SEL2=0;
+  SEL1=1;*/
+  
+  
+  i=0;
+    
+    while(1){
+       
+       while(1) {
+    
+        cifra=jedinica[i];
+        SEL2=0;
+        SEL1=1;
+    
+    
+        wait_ms(PERIOD);
+    
+         
+        cifra=desetica[i];
+        SEL2=1;
+        SEL1=0;
+    
+        wait_ms(PERIOD);
+     
+        if(!SW1){  // if start
+         i=i++;
+         i=i%16;
+         
+         break;
+         
+         }// if end
+       }
+// while inner    
+    
+    
+    
+    } // while outer  
+
+
+
+}  // main