Calculadora por puerto serial, coolterm.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jiuk
Date:
Fri Aug 17 12:43:45 2018 +0000
Commit message:
Adicionamos codigo Dbug

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	Fri Aug 17 12:43:45 2018 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#define DEBUG 1
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+void mdebug(char *s){
+    #if DEBUG
+        pc.printf(s);
+    #endif
+    }
+
+void f_p(int N){
+    pc.printf("La resuesta es: %d ", N );
+    //char c=N/100;
+    //char d=(N/10) -(c*10/10);
+    //char u=N-c*100-d*10;
+    //pc.putc(c);pc.putc(d);pc.putc(u);
+    //pc.printf("%d, %d, %d",c,d,u);
+    }
+
+int main()
+{
+    pc.baud(9600); //velocidad de funcionamiento
+    void f_p(int N);
+    char op1;
+    char op2;
+    char tp;
+    int rst;
+    while(1) {
+        //pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF \r\n");
+        mdebug("\nIngrese dato 1: \n");
+        op1=pc.getc();
+        printf("%d ",op1);
+        mdebug("Ingrese dato 2: \n");
+        op2=pc.getc();
+        mdebug("Ingrese el operador: \n");
+        //mdebug("1=mul 2=div 3=sum 4=res ");
+        tp=pc.getc();
+        //printf("op1=%d,op2=%d",op1,op2);
+        switch (tp){
+            case 1:rst=op1*op2;
+            break;
+            case 2:rst=op1/op2;
+            break;
+            case 3:rst=op1+op2;
+            break;
+            case 4:rst=op1-op2;
+            break;
+            default:rst='E';
+            break;
+            }
+        f_p(rst);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Aug 17 12:43:45 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a7c7b631e539
\ No newline at end of file