Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 接收从处理到arduino的字符串_Java_Arduino_Processing - Fatal编程技术网

Java 接收从处理到arduino的字符串

Java 接收从处理到arduino的字符串,java,arduino,processing,Java,Arduino,Processing,我想从processing接收到arduino的字符串。我正在写一个字符串(基本上是一个字符串形式的单位数数组,例如:是一个数组:0 2 1 3)。我可以将其写入端口,但如何在arduino上接收?以下代码将发送给arduino int[] send={0,2,3,1}; myPort =new Serial(this,"/dev/ttyACM0", 9600); String theStg = "<" + nf(send[0], 3) + " " +

我想从processing接收到arduino的字符串。我正在写一个字符串(基本上是一个字符串形式的单位数数组,例如:是一个数组:0 2 1 3)。我可以将其写入端口,但如何在arduino上接收?以下代码将发送给arduino

int[] send={0,2,3,1};
myPort =new Serial(this,"/dev/ttyACM0", 9600);
String theStg = "<" + nf(send[0], 3) +
                   " " + nf(send[1], 3) +
                   " " + nf(send[2], 3) +
                   " " + nf(send[3], 3) +
                   ">";
myPort.write(theStg); 
int[]send={0,2,3,1};
myPort=new Serial(这是“/dev/ttyACM0”,9600);
字符串theStg=“”;
myPort.write(theStg);

如果您使用的是char*字符串,而不是string类,那么您可以使用command

这一问题已经得到解决

您只需在代码中添加与strtok()等效的内容,但只需在字符串对象上添加即可。