bluetooth link

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ARK4579
Date:
Sat Jan 02 11:37:44 2016 +0000
Commit message:
blutooth control

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 Jan 02 11:37:44 2016 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+
+//bluetooth module employs Serial Communication.
+Serial blutooth(PA_9, PA_10);//Tx, Rx
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+DigitalOut myled(LED1); //LED on your Nucleo Board
+DigitalIn btn1(PC_13);  //Button on your Nucleo Board
+
+int main()
+{
+    char t1,t2,h1,h2;
+    int it1,it2,ih1,ih2;
+    int it,ih;
+    //This will print Hello World onto your SmartPhone
+    blutooth.printf("Hello World !\r\n");
+    while(1) {
+        if(blutooth.readable()) {
+            if(blutooth.getc()=='t') {
+                blutooth.printf("Enter temp: ");
+                while(1) {
+                    if(blutooth.readable()) {
+                        t1=blutooth.getc();
+                        it1 = t1 - '0';
+                        break;
+                    }
+                }
+                while(1) {
+                    if(blutooth.readable()) {
+                        t2=blutooth.getc();
+                        it2 = t2 - '0';
+                        break;
+                    }
+                }
+                it = it1*10 + it2;
+                pc.printf("temp: %d\r\n",it);
+            }
+        }
+        if(blutooth.getc()=='h') {
+            blutooth.printf("Enter temp: ");
+            while(1) {
+                if(blutooth.readable()) {
+                    h1=blutooth.getc();
+                    ih1 = h1 - '0';
+                    break;
+                }
+            }
+            while(1) {
+                if(blutooth.readable()) {
+                    h2=blutooth.getc();
+                    ih2 = h2 - '0';
+                    break;
+                }
+            }
+            ih = ih1*10 + ih2;
+            pc.printf("hum: %d\r\n",ih);
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 02 11:37:44 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file