Hello,
This was just a quick look at this !
I have a lot of experience getting examples working. :)
Try this:
Arduino Code
void setup()
{
Serial.begin(115200);
}
void loop()
{
// Print the temperature value of each pixel in floating point degrees Celsius
// separated by commas
float temp = 10.00;
for(unsigned char i = 0; i < 64; i++)
{
//Serial.print(grideye.getPixelTemperature(i));
Serial.print(temp, 2);
Serial.print(",");
temp += 0.25;
}
// End each frame with a linefeed
Serial.println();
// Give Processing time to chew
delay(100);
}
Processing Code
if(myPort.available() > 64)
{
myString = myPort.readStringUntil(13);
// generate an array of strings that contains each of the comma
// separated values
//println(myString);
if (myString != null)
{
trim(myString);
String splitString[] = splitTokens(myString, ",");
//printArray(splitString);
if (splitString.length == 65) //65 for that last bit of data after the last ',' !
{
// for each of the 64 values, map the temperatures between 20C and 40C
// to the blue through red portion of the color space
for(int q = 0; q < 64; q++)
{
temps[q] = map(float(splitString[q]), 20, 40, 240, 360);
}
//printArray(temps);
}
}
}
Please take a close look at what I did.
I added a lot of checks!
I used trim to remove the linefeed (goes along for the ride from println()) before splitting it.
I added a lot of print statements to see what was being received; uncomment these to understand this.
The data length of spitString array is actually 65 because there is an empty string after the last ‘,’
That is a lot of zeroes!
//float[] temps = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float[] temps = new float [64];
printArray(temps);
:)