Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SoftSerial TextLCD mbed
Fork of String_BT by
main.cpp
- Committer:
- dimmu8410
- Date:
- 2017-03-11
- Revision:
- 1:34f5a73ebf6c
- Parent:
- 0:b693dce679a4
- Child:
- 2:38579897448f
File content as of revision 1:34f5a73ebf6c:
#include "mbed.h"
#include "SoftSerial.h"
#include <string>
int ledPin = 13;
string readString;
char c[125];
AnalogIn ai(A0);
float measure;
SoftSerial BT(D2,D3);
Serial pc(USBTX,USBRX);
DigitalOut led(LED2);
int main()
{
pc.baud(9600);
BT.baud(9600);
while(1)
{
while (BT.readable()>0)
{
wait(0.003);
//char c = BT.getC();
BT.gets(c,2);
readString += c;
}
if (readString.length()>0)
{
pc.printf("%s",readString);
//pc.printf("%s\r\n",readString);
if (readString == "1")
{
led=!led;
wait(0.5);
}
if (readString == "FO")
{
led=0;
}
if (readString == ".")
{
pc.printf("\n\r");
}
if (readString == "AL")
{
measure=ai.read_u16()*0.00005;
BT.printf("%f",measure);
}
readString="";
c[0]=' ';
c[1]=' ';
c[2]=' ';
}
}
}
