We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi I'm very new to all of this, hope to formulate the question right.
In my project I have 5 sensors connected to Arduino, which I want to interpret via Seria.write() --> Processing.
Arduino:
firstSens = 100 + (155 * digitalRead(8));
secondSens = analogRead(A1)/4;
thirdSens = analogRead(A2)/4;
fourthSens = humData;
fifthSens = tempData;
int sensData[6] = {firstSens, secondSens, thirdSens, fourthSens, fifthSens};
int i;
for (i = 0; i < 5; i = i + 1) {
Serial.write(sensData[i]);
}
Processing:
serialInArray[serialCount] = inByte;
serialCount++;
if (serialCount > 4 ) {
firstSens = serialInArray[0];
secondSens = serialInArray[1];
thirdSens = serialInArray[2];
fourthSens = serialInArray[3];
fifthSens = serialInArray[4];
println(firstSens + "\t" + secondSens + "\t" + thirdSens + "\t" + fourthSens + "\t" + fifthSens);
myPort.write('A');
serialCount = 0;
My problem is that sensors find their place in Processing's array randomly, so for example arduino's firstSens
could be Processing's secondSens
or fifthSens
Why is this happening and how can I control it?
Answers
forum.Processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
https://forum.processing.org/two/discussion/17275/arduino-sensorshieldlib-json-communication