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