BlueeTooth

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
59340500018
Date:
Wed Nov 22 11:53:31 2017 +0000
Commit message:
BlueTooth;

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 c3549f40bdba main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 22 11:53:31 2017 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+Serial bt(D8, D2);
+AnalogIn analog_value(A1);
+BusOut segment(D3,D4,D5,D7);
+
+int main()
+{
+    uint8_t state_menu=0;
+    uint8_t state_show=0;
+    uint8_t state_exit =0;
+    uint8_t data;
+
+    //myled = 0;
+    bt.readable();
+    bt.printf("ASevenZ");
+    while(1) {
+        if(state_show == 0) {
+            bt.printf("************\n");
+            bt.printf("   Menu   \n");
+            bt.printf("************\n");
+            bt.printf("1.Segment Function\n");
+            bt.printf("2.Read VR\n");
+            state_show =1;
+            }
+        if(bt.readable()) {
+            data = bt.getc();
+            bt.printf("\n");
+            state_show =0;
+            state_exit =0;
+
+            switch(data) {
+                case '1':
+                    do {
+                        if(bt.readable()) {
+                            data = bt.getc();
+                            if (data=='s'){
+                                segment = 0;
+                                state_exit =1;
+                                break;
+                            }
+                            segment = data;
+                            bt.printf("data: %d\n", data);
+                            state_menu = 0;                        
+                        }
+                    }
+                while(state_exit == 0);
+                bt.printf("break\n");
+                break;
+            
+                case '2':
+                    do {
+                        if(bt.readable()) {
+                            data = bt.getc();
+                            if (data=='s'){
+                                bt.printf("\n");
+                                state_exit =1;
+                                break;
+                            }
+                        }
+                        float VR = 0;
+                        VR = analog_value.read();
+                        VR = VR * 3.3f;
+                        bt.printf("VR: %.2f \n",VR);
+                        }
+                while(state_exit ==0);
+                bt.printf("\n");
+                break;
+    
+                default:
+                    bt.printf("plz select 1 or 2 \n");
+                    bt.printf("\n");
+                    break;
+            }
+        }
+    }
+}
+
diff -r 000000000000 -r c3549f40bdba mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 22 11:53:31 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb
\ No newline at end of file