Panusorn Chinsakuljaroen
/
BTF411
Bluetooth for f411re reciever
Diff: main.cpp
- Revision:
- 0:75e3c6b099a6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 04 20:23:30 2018 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" +#include <string> +#include <stdio.h> +#include <cstdlib> + +Serial pc(USBTX, USBRX); +Serial serial(D8,D2); +char data[50]; +string dat[4],dat1,dat2,dat3,dat4; +float num[4],numx; +int i; +const char * d; + +int main() { + pc.baud(115200); + i=0; + while(1) { + if(serial.readable() ) { + + serial.scanf("%50s", data); + dat[i]=data; + num[i] = atof(data); + pc.printf("%s \r\n",data); + pc.printf("%s \n",dat[0]); + pc.printf("---------------\n"); + i=i+1; + if(i>3){i=0;} + +/* + dat1=dat2; + dat2=dat3; + dat3=data; + serial.scanf("%50s", data); + d=dat1.c_str(); + numx=atof(d); + pc.printf("%s \r\n", d); +*/ + } + } +} \ No newline at end of file