![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
bluetooth link
Diff: main.cpp
- Revision:
- 0:ecf84ddda5e9
diff -r 000000000000 -r ecf84ddda5e9 main.cpp --- /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