我配置了三个串口。
我想将函数的输出切换到这三个端口中的任何一个。
Ports有#define
个语句给他们友好的名字
#define Port0 Serial
#define Port1 Serial1
#define Port2 Serial2
String destination_select;
我正在尝试做类似的事情:
void port_select(int selectPORT){
if (selectPORT == 0){
destination_select = PORT0;
}
else if (selectPORT == 1){
destination_select = PORT1;
}
else if (selectPORT == 2){
destination_select = PORT2;
}
}
void mycommand(){
port_select(0);
// Prints to Port 0
destination_select.println("Port0");
port_select(1);
// Prints to Port 1
destination_select.println("Port1");
port_select(2);
// Prints to Port 2
destination_select.println("Port2");
}
这不起作用,但我不知道如何使其发挥作用。