Stefan Veljkovic 2020/0158

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
1stefikefi
Date:
Sat Nov 06 08:46:22 2021 +0000
Commit message:
Stefan Veljkovic 2020/0158

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 06 08:46:22 2021 +0000
@@ -0,0 +1,86 @@
+/*
+    Stefan Veljkovic 2020/0158
+*/
+
+
+#include <mbed.h>
+
+#define WAIT 0.0005
+        //   A      B     C     D     E     F      G
+BusOut DISPLAY(PA_10, PA_9, PA_8, PB_10, PB_5, PB_4, PB_3);
+//BusOut DISPLAY(PB_3, PB_4, PB_5, PB_10, PA_8, PA_9, PA_10);
+DigitalOut SEL1 = PB_6;
+DigitalOut SEL2 = PC_7;
+DigitalIn taster1 = PC_9;
+DigitalIn taster2 = PC_8;
+
+int main()
+{
+    int i = 0;
+    while(true)
+    {
+        if(!taster1)
+        {
+            if(i == 15)
+            {
+                i = 0;
+                wait(0.15);
+            }
+            else
+            {
+                i = i + 1;
+                wait(0.15);
+            }
+        }
+        if(!taster2)
+        {
+            if(i == 0)
+            {
+                i = 15;
+                wait(0.15);
+            }
+            else
+            {
+                i = i - 1;
+                wait(0.15);
+            }
+        }
+        switch(i)
+        {
+            //case -1: i = 15; break;
+            case 0: DISPLAY.write(0xC0); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 1: DISPLAY.write(0xF9); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 2: DISPLAY.write(0xA4); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 3: DISPLAY.write(0xB0); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 4: DISPLAY.write(0x99); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 5: DISPLAY.write(0x92); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 6: DISPLAY.write(0x82); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 7: DISPLAY.write(0xF8); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 8: DISPLAY.write(0x80); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 9: DISPLAY.write(0x90); SEL1.write(1); SEL2.write(0); if(!taster1); break;
+            case 10:DISPLAY.write(0xC0); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            case 11:DISPLAY.write(0xF9); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            case 12:DISPLAY.write(0xA4); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            case 13:DISPLAY.write(0xB0); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            case 14:DISPLAY.write(0x99); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            case 15:DISPLAY.write(0x92); SEL1.write(1);SEL2.write(0); wait(WAIT);
+                    DISPLAY.write(0xF9); SEL1.write(0);SEL2.write(1); wait(WAIT);
+                    break;
+            //case 16: i = 0; break;
+        }
+        /*DISPLAY.write(0xC0);
+        SEL1.write(1);
+        SEL2.write(0);
+        */
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 06 08:46:22 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file