我在arduino中有一个传感器,它通过bluethooth发送int数据,例如,我需要在句子中使用它
number delivered by bluetooth <100
do something
#include<SoftwareSerial.h>
SoftwareSerial miBT(11,10);
int measurePin=0;
intledPower=12;
int samplingTime =280;
int deltaTime=40;
int sleepTime =9680;
float voMeasured=0;
float calcVoltage=0;
float dustDnesity=0;
float pm05=999;
String pm05t="hola";
void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
// serial.begin(9600);
Serial.println(pm05);
miBT.begin(38400);
}
void loop(){
digitalWrite(ledPower,LOW); // power on the ED
delaymicroseconds(sampleTime);
voMeasured=analogRead(measurePin); // read the dust value
delayMicrosecond(deltaTime);
digitalWrite(ledPower,HIGH); //turn the LED off
delayMicrosecods(sleepTime);
// 0-3.3V mapped to 0-1023 integer values
//recover voltage
calcVoltage = 5*voMeasured/1024;
//Chris Nafis (c) 2012
dustDensity= 0.17 * calcVoltage-0.1;
//Ecuacion linear de PM 2.5
//Serial.print("- Voltage: ");
//SErial.print(calcVoltage);
//Serial.print("- Dust Density (mg/m3): ");
//Serial.println(dustdensity);
//SErial.print (" - PM 0.5 (particulas/0.01 ft3): ");
//Serial.println (pm05);
delay(2000)
//Serial.write(pm05);
if(miBT.avalible())
miBT.write(Serial.read()) //read arduino and send to BT
miBT.write("pm05"); //read arduino and send to BT
//miBT.read("Holad"); //read arduino and send to BT
这是arduino代码,我在此处有该应用程序的图片,我需要获取尘埃密度的值,并且如果该值大于0且小于300000,则需要一个绿色的圆圈,如果它大于300000并且小于450000圆圈是黄色的,我将图像放在这里