数据例子
通过串口3接受 WHITE:12345GREEN:54321RED:12345BLUE:12345 ,解析出 四种颜色对应的值
代码
void setup() {
// put your setup code here, to run once:
Serial3.begin(115200, SERIAL_8N1);
}
while (Serial3.available() > 0)
{
getDat += char(Serial3.read());
}
pos = getDat.indexOf(":");
SWRevision = getDat.substring(pos + 1, pos + 6);
revision = SWRevision.toInt();
pos = getDat.indexOf(":", 10);
StatusFlag = getDat.substring(pos + 1, pos + 6);
pos = getDat.indexOf(":", 18);
Calibration = getDat.substring(pos + 1, pos + 6);
pos = getDat.indexOf(":", 27);
Current = getDat.substring(pos + 1, pos + 6);
结果