Plotting sensor output from photodiode array

Hello,

I am working with die TSL1402R linear sensor array for a little project. I've found a description on the playground-site: Arduino Playground - TSL1402R

Everything works fine with the code, except for the plot of the data. I want to have it look like the plot on the site, it looks like a spectrum and displays intensity of every pixel of the sensor. unfortunately there are no information about the plotting program.

With the serial plotter in the Arduino IDE, I can display the data only as a function of time, which means I get 256 plots at the same time.

I've tried it with Processing to draw the data like a histogram. but that didn't worked neither.
Has anybody an idea to do it?

My Processing code looks like this (hope that nobody is bothered about my german comments :-P):

import processing.serial.*;//Serielle Bibliothek importieren

Serial myPort;//myPort Objekt erstellen
int[] data = new int[256];
int[] storedData;
String inString;

void setup() {
  size(1023, 511);//Fenster erstellen
  background(0);//Hintergrundfarbe schwarz waehlen
  fill(255);
  printArray(Serial.list());//Liste der vorhandenen Ports ausgeben
  myPort = new Serial(this, Serial.list()[1], 9600);//seriellen Port auswählen und initalisieren
  myPort.clear();
  //myPort.bufferUntil('\n');//Ende eines Datenblocks definieren
  myPort.buffer(32);
  myPort=null;
}

void draw() {
  if(data != null) {
    for(int i = 0; i < data.length; i++){
      rect(i*4, height-(data[i]/2), 3, data[i]/2);//4*256=1024; Rechteck mit Position: (i*4)/height und Groesse: 3x-data[i]/2
    }
  }
}

void serialEvent(Serial myPort) {
  inString = myPort.readString();
  background(0);
  inString = trim(inString);
  int[] storedData = int(split(inString, ' '));
  data = reverse(storedData);
}

best regards
Melvin

  //myPort.bufferUntil('\n');//Ende eines Datenblocks definieren

Why did you comment that line out? With that commented out, the serialEvent() function will be called whenever there is any data to read, not just when the complete set of values arrives.

Thanks for your reply.
I used myPort.buffer(32) to buffer 32 Bytes (256 values). Tried it with myPort.bufferUntil('\n') before, but that worked neither.

I used myPort.buffer(32) to buffer 32 Bytes (256 values).

32 bytes might well be 256 bits, but you are not sending bits. You are sending 256 strings separated by semicolons.

In Processing, you are splitting the string that you read at the spaces. There are NO spaces in the data that you get, unless you changed the Arduino code on the playground.

Print the string that you read, between delimiters, so you can see what you are trying to split. You will see that it contains nowhere near 256 semicolons.