PlainProtocol write 通过蓝牙发送 接收端数据时而为null
2015-03-171.1万
AI 快速预览详细
本文讨论了使用PlainProtocol库通过蓝牙发送传感器数据时遇到的数据为null的问题。通过调整代码中的延迟时间和初始化顺序,可以有效解决这一问题。示例代码展示了如何读取模拟和数字传感器数据,并通过蓝牙发送。
|
#include <PlainProtocol.h> PlainProtocol mytest(Serial, 57600); const int waterPin = 10; void setup() { mytest.init(); pinMode(waterPin,INPUT); } void loop() { int t_analogValue;//analog t_analogValue = analogRead(0); //connect Steam sensors to Analog 0 int t_digitalValue = LOW; //default digital low t_digitalValue = digitalRead(waterPin); //low is sending if(t_digitalValue == LOW){ mytest.write("T_A|T_D",t_analogValue,t_digitalValue);//send analogValue and digitalValue } delay(1000); } |




解决方法
e01866fe 66000606 66fe6660 f818781e 18188600