Im trying to pass an array of int values from my Arduino to a processing sketch threw a serial link.
But I need to convert the data collected from the sketch to int values. And that's where's the problem
in the first case, it returns me 0 every time even if I change the value and in the other case it returns me an error. I can't understand anything can you help me?
There is the code on the arduino !
int Rx = 7 , Ry = 5, Rz = 15, Tx = 89, Ty = 56, Tz = 75;
int coord[6] = {Rx, Ry, Rz, Tx, Ty, Tz};
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < 6; i++) {
Serial.println(coord[i]);
Serial.println("/");
}
Serial.println("|");
}
and that's the processing sketch.
import processing.serial.*;
Serial port;
String myString;
int val;
void setup() {
//size(1200,600);
String portName = Serial.list()[1];
port = new Serial(this, portName, 9600);
}
int Rx = 0, Ry = 0, Rz = 100, Tx = 0, Ty = 0, Tz = 0;
void draw() {
if (0 < port.available()) {
myString = port.readStringUntil('|');
if (myString != null) {
println(myString.split("/")[2]);
val = int(myString.split("/")[2]);
println(val);
}
}
}
the problem is that val is always equal to 0.
thank's for your help and I'm sorry for my english.