【发布时间】:2015-05-19 17:11:37
【问题描述】:
我试图通过 Xbee 和 Arduino 简单地发送“1”或“2”。我的 Arduino TX 正在 Serial.print 成功打印“1”或“2”,但 RX 没有收到相同的结果。
TX:
void buttonBring()
{
delay(75);tone(speakerpin,660,300);
delay(75);tone(speakerpin,330,300);
digitalWrite(ledpin, HIGH);
//Serial.println("Button B is Ringing");
Serial.write("2");
delay(600);
}
RX:接收到的值为
126
0
6
129
0
0
44
2
50
30
接收代码:
void loop() {
if (xBee.available()) {
byte bell = xBee.read();
Serial.println(bell, DEC);
}
我想只接收 1 或 2 甚至 A 或 B,以便接收者可以做出决定或使用 switch case,但 rx 必须是 yes 或 no 格式。我怎么搞砸了?
【问题讨论】: