|
我用两块hc-05蓝牙模块将两块uno连接之后,怎么能发送以下这样的数据格式(三个模拟口读取):
12,34,56
23,42,87
18,94,74
。。。
现在只会发送一个模拟口的数据,代码是这样的:
主机代码:
#include<SoftwareSerial.h>
SoftwareSerial BlueTooth(8,9);
int val;
void setup() {
Serial.begin(9600);
BlueTooth.begin(9600);
val=0;
}
void loop() {
if (BlueTooth.available()>0) {
val=BlueTooth.read();
}
Serial.println(val);
}
从机代码:
#include<SoftwareSerial.h>
SoftwareSerial BlueTooth(8,9);
int val;
void setup() {
Serial.begin(9600);
BlueTooth.begin(9600);
}
void loop() {
val=analogRead(A0);
BlueTooth.write(byte(val));
}
求大神指点一下
|
|