I have an arduino test wether two wires touch, this works. The data is stored in an array for each pin and given either a 1 or 0 if the wire connects to another. The Serial.print is used to send the data, the serial monitor shows the data is correct. However in processing where this data is used it seems to not update. If I touch the wires before starting processing it knows they touch, but when I release the wires processing says they still touch. Same happens if they don’t touch at the start. This really frustrates me, because the data is sent correctly. And I have to deliver this project in 5 hours.
Arduino code:
void sendArrayData() {
for (int i = 0; i < 12; i++) {
Serial.print(",");
Serial.print(i);
Serial.print(",");
if (i < 11) {
Serial.print(partsConnected[i]);
} else {
Serial.println(partsConnected[i]);
}
}
}
Processing code:
void SerialEvent() {
myString = myPort.readStringUntil('\n');
if (myString != null) {
myString = trim(myString);
println(myString);
sensors = int(split(myString, ','));
}
}
Example data when two wires touch for the first time after the program has run for a little second already.
The data sent by Arduino example if first two wires connect: ,0,1,1,1,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0
The data recieved by Processing: ,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0