nearly working

Dependencies:   mbed

Revision:
1:093493ce0f37
Parent:
0:4592a95188f3
--- a/main.cpp	Sun Feb 07 19:54:00 2021 +0000
+++ b/main.cpp	Tue Feb 09 16:53:53 2021 +0000
@@ -1,26 +1,104 @@
 #include "mbed.h"
+#include <string>
+#include <iostream>
+using namespace std; 
 
 BusOut LED_Disp(p7,p11,p9,p8,p5,p6,p10,p12);
 
-InterruptIn plusbutton(p14);
-InterruptIn minusbutton(p15);
-DigitalOut led1(LED1);
-DigitalOut flash(LED3);
+InterruptIn button1(p14);
+InterruptIn button2(p15);
+volatile bool button1Up = true;
+volatile bool button2Up = true;
+volatile unsigned int counter = 0;
+
+void DisplayNumber(int num, BusOut &Bus)
+{
+    num = num % 10;
 
-void flip() 
-{
-    led1 = !led1;
+    switch(num)
+    {
+        case 0:
+            LED_Disp = ~0x3F;
+            break;
+        case 1:
+            LED_Disp = ~0x06;
+            break;
+        case 2:
+            LED_Disp = ~0x5B;
+            break;
+        case 3:
+            LED_Disp = ~0x4F;
+            break;
+        case 4:
+            LED_Disp = ~0x66;
+            break;
+        case 5:
+            LED_Disp = ~0x6D;
+            break;
+        case 6:
+            LED_Disp = ~0x7D;
+            break; 
+        case 7:
+            LED_Disp = ~0x07;
+            break;
+        case 8:
+            LED_Disp = ~0x7F;
+            break;
+        case 9:
+            LED_Disp = ~0x67;
+            break; 
+    }
+}
+
+void up1(){
+    button1Up = true;
+}
+
+void down1(){
+    button1Up = false;
+}
+
+void up2(){
+    button2Up = true;
+}
+
+void down2(){
+    button2Up = false;
 }
 
 int main()
 {
-    plusbutton.rise(&flip);
-    while(1)
-    {
-        flash = !flash;
-        wait(0.25);
+    button1.rise(&down1);
+    button1.fall(&up1);
+    button2.rise(&down2);
+    button2.fall(&up2);
+          
+    while(1){
+        LED_Disp = -1;
+        while(!button1Up)
+        {
+            DisplayNumber(counter, LED_Disp);
+            counter++;
+            
+        }
+        while(!button2Up)
+        {
+            DisplayNumber(counter, LED_Disp);
+            counter--;
+            
+        }
     }
+    
+    
 }
+            
+                
+    
+
+
+    
         
-        
+                
+            
+            
         
\ No newline at end of file