|
本帖最后由 ndtjxxx 于 2016-4-3 18:45 编辑
Duemilanove的串口脚是数字0和数字1,与安卓板进行串口通讯,安卓板的串口是RX TX各占一个引脚,但ARDUINO用下面的代码,接受发送都只用一个数字0脚,怎么让RX 和TX各自使用数字0和数字1脚?
String inputString = "";
boolean stringComplete = false
void setup() {
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
}
void loop() {
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(inputString);
// clear the string:
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|