Carlos Quintana / Mbed 2 deprecated frdm_gpioInterrupcion

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Otakutronics
Date:
Tue Dec 18 01:21:25 2018 +0000
Commit message:
Contador up/down con display 7 segmentos multiplexado

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 cee1c4dd8c94 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 18 01:21:25 2018 +0000
@@ -0,0 +1,106 @@
+#include "mbed.h"
+/*
+DigitalOut gpo(D0);
+DigitalOut led(LED_RED);
+*/
+//><
+DigitalOut  BjtUnd(PTA2,1);
+DigitalOut  BjtDcn(PTA1,1);
+
+InterruptIn BtnInc(PTE25);
+InterruptIn BtnDec(PTE24);
+
+PortOut OutC(PortC,0x000000FF);
+PortOut OutD(PortD,0x000000FF);
+
+unsigned char unidades, decenas;
+
+void ISR_Incrementar(){
+    
+    unidades ++;
+    if (unidades == 10){
+        unidades = 0;
+        decenas ++;
+        if (decenas == 10){
+            decenas = 0;
+        }
+    }
+    wait_ms(30);    
+}
+
+void ISR_Decrementar(){
+
+    unidades --;
+    if (unidades == 0xFF){
+        unidades = 9;
+        decenas --;
+        if (decenas == 0xFF){
+            decenas = 9;    
+        }   
+    } 
+    wait_ms(30);  
+}
+
+void BinToDisplay(unsigned char num){
+    switch (num){
+        case 0: OutC.write(0);
+                OutD.write(8);
+                break;
+        case 1: OutC.write(3);
+                OutD.write(11);
+                break;    
+        case 2: OutC.write(4);
+                OutD.write(2);
+                break; 
+        case 3: OutC.write(2);
+                OutD.write(2);
+                break; 
+        case 4: OutC.write(3);
+                OutD.write(1);
+                break; 
+        case 5: OutC.write(2);
+                OutD.write(4);
+                break; 
+        case 6: OutC.write(0);
+                OutD.write(5);
+                break; 
+        case 7: OutC.write(3);
+                OutD.write(10);
+                break; 
+        case 8: OutC.write(0);
+                OutD.write(0);
+                break;
+        case 9: OutC.write(3);
+                OutD.write(0);
+                break;  
+    }   
+}
+
+int main()
+{
+    BtnInc.mode(PullUp);
+    BtnDec.mode(PullUp);
+    
+    BtnInc.rise(&ISR_Incrementar);
+    BtnDec.rise(&ISR_Decrementar);
+    
+    unidades = 0;
+    decenas = 0;
+    
+    while (true) {
+        
+        BinToDisplay(unidades);
+        BjtUnd = 0;
+        BjtDcn = 1;
+        wait(0.02);
+        BinToDisplay(decenas);
+        BjtUnd = 1;
+        BjtDcn = 0;
+        wait(0.02);
+/*
+        gpo = !gpo; // toggle pin
+        led = !led; // toggle led
+        wait(0.2f);
+*/
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r cee1c4dd8c94 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 18 01:21:25 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file