你可以使用arduino,但不是普通的,你需要一个mega,我这么说是因为ardiono mega是我所知道的唯一一个具有多个串行UART的arduino。例如,Uno 使用与 USB 接口相同的 UART 共享 RX/TX 串行引脚。
如果你有一个兆,你可以得到一个便宜的 USB 到串行模块,例如:http ://www.ebay.com/sch/i.html?_from=R40&_sacat=0&_nkw=arduino+usb+to+serial&_sop= 15
现在,您将 PC 插入 mega 的普通 USB,这将从您的 PC 为 Mega 供电。然后将平板电脑连接到串行模块。
剩下要做的就是为您的 mega 创建一个简单的 ino 脚本,以将数据从串行(pc-USB)传输到串行 2(平板电脑),反之亦然。
例子:
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); // PC <--> USB
Serial1.begin(115200); // Serial <--> Tablet
}
void loop() {
// put your main code here, to run repeatedly:
serialComs(); // Tells loop to execute the serialComs() function
}
// Serial Comunication function
void serialComs() {
// read from port 1 (Tablet), send to port 0 (PC):
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0 (PC), send to port 1 (Tablet):
if (Serial.available()) {
int inByte = Serial.read();
Serial1.write(inByte);
}
}
注意:您可能需要在 void setup 之前添加#DEFINE 条目,以定义串行转 USB 模块上的哪些引脚。