O.k. so I am fairly new to processing and I have developed several cool interfaces and I am currently trying to get my newest interface to display current data from an arduino light sensor . I can view the data in the console log, however every attempt to render on the screen gets a null pointer error.... I know it is something simple, just can't seem to figure it out.
here is my arduino code:
int lightPin = 0; //define a pin for Photo resistor
int ledPin=13; //define a pin for LED
void setup()
{
Serial.begin(9600); //Begin serial communcation
pinMode( ledPin, OUTPUT );
}
void loop()
{
if(Serial.available() > 0){
Serial.read();
Serial.print("Hello World");
Serial.print("*");
/*
Serial.print(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
digitalWrite(ledPin,HIGH); //send the value to the ledPin. Depending on value of resistor
digitalWrite(ledPin,LOW);
Serial.print("*");
delay(300);*/
}
}
Here is my processing code:
import processing.serial.*;
Serial myPort; // The serial port
PImage wood;
PFont rok;
void setup(){
size(1280,800);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
rok = loadFont("rok.vlw");
textFont(rok,60);
wood = loadImage("wood.png");
smooth();
myPort.write(65);
}
void draw() {
background(255);
fill(0);
textFont(rok,24);
text("Data Logger v 1.0",10,20);
image(wood,385,80);
statusUpdate();
}
void statusUpdate(){
if (myPort.available() > 0) {
String input = myPort.readStringUntil('*');
println(input);
//text(input,100,100); // this is where my error occurs????? How can I use the incoming data