Processing Forum
This is caused by this line "Old[0] = 0;".Exception in thread "Animation Thread" java.lang.NullPointerException
at I2C_Plot.setup(I2C_Plot.java:33)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:636)
import processing.net.*;Any ideas? Thanks for your time.
Client C;
String data;
int X = 1;
int[] Old;
int[] Now;
void setup() {
size(600,200); smooth(); background( 0 );
C = new Client( this, "127.0.0.1", 5204 );
Old[0] = 0;
}
void draw() { }
void clientEvent( Client C ) {
println("Event"); int Yes;
while( ( Yes = C.available() ) > 0 ) {
println("read: " + Yes);
data = C.readStringUntil( '\n' );
print(data);
Now = int( splitTokens( data, " \n" ) );
println(data);
if( Now[0] != Old[0] ) { line( X, 10, X, 20 ); }
point( X, 10 + ( Now[0] * 10 ) );
Old[0] = Now[0];
if( ++X > 600 ) X = 1;
}
}