Well, I don’t have any Arduino hardware and neither even seen 1 in front of me yet!
So I can only do blind coding in the dark for you.
Theoretically, an Arduino C code like this 1:
void setup() {
Serial.begin(115200);
}
void loop() {
const int x = map(analogRead(A1), 0, 1023, -10, 10);
const int y = map(analogRead(A0), 0, 1023, -10, 10);
Serial.print(x); // "-5"
Serial.write('\t'); // '\t'
Serial.println(y); // "10" + "\r\n"
delay(2);
}
Should expect to send an output similar to this 1 on each of its loop(), right:
String tsv = "-5" + '\t' + "10" + "\r\n";
println(tsv); // -5 10
int[] vals = int(splitTokens(tsv));
println(vals); // [0] -5 [1] 10
exit();
So AFAIK, a Processing Java code like this 1 should hopefully work for your case:
import processing.serial.Serial;
static final int VALS = 2;
int[] vals = new int[VALS];
void setup() {
size(800, 600);
noLoop();
stroke(-1);
clear();
final String[] ports = Serial.list();
printArray(ports);
new Serial(this, "COM12", 115200).bufferUntil(ENTER);
}
void draw() {
println(vals);
}
void serialEvent(final Serial s) {
vals = int(splitTokens(s.readString()));
redraw = true;
}