Trouble getting Processing to graph temp sensor readings correctly from Arduino.

Hey guise!
I programmed an LM35 temperature sensor and I am trying to get Processing to correctly communicate with Arduino and graph the temperature sensor readings. Although I got them to communicate, for some reason Processing refuses to graph the readings and my temperature sensor readings became totally unreadable. I am also getting the error Null Pointer Exception in my processing code in the line while(scope.available() > 0). I am aware of what Null Pointer Exception is but I don’t know how to fix it in my code. Any ideas?
Any help would be greatly appreciated!
Thanks!

Here is the code I am using for Arduino:

int analogPin = 0;
int readValue = 0;
float temperature = 0;
float temperatureF = 0;
void setup() {
Serial.begin(9600);
}

void loop() {
readValue = analogRead(analogPin);
//Serial.println(readValue);
temperature = (readValue * 0.0049);
temperature = temperature * 100;
temperatureF = (temperature * 1.8) + 32;
Serial.print(readValue);
Serial.print(" Temperature: ");
Serial.print(temperature);
Serial.print("C ");
Serial.print(temperatureF);
Serial.println(“F”);
delay(1000);
}

And here is the code I am using for Processing

//import Serial communication library
import processing.serial.*;

//init variables

Serial scope;
String adaptor= “/dev/cu.usbmodem1431”;
//Serial port;
float tempC;
float tempF;
int yDist;
PFont font12;
PFont font24;
float tempHistory = new float[100];

void setup()
{
//setup fonts for use throughout the application
font12 = loadFont(“Verdana-12.vlw”);
font24 = loadFont(“Verdana-12.vlw”);

//set the size of the window
size(210, 200);

//fill tempHistory with default temps
for(int index = 0; index<100; index++)
tempHistory[index] = 0;
}

void portConnect(){
int portNumber = 99;
String ports;
println(Serial.list());
ports = Serial.list();
for(int j = 0; j< ports.length; j++) {
if(adaptor.equals(Serial.list()[j])) portNumber = j;
}
if(portNumber == 99) portNumber = 0;
String portName = Serial.list()[portNumber];
println("Connected to "+portName);
scope = new Serial(this, portName, 9600);
scope.bufferUntil(10);
}

void serialEvent(Serial scope) { // this gets called every time a line feed is received
String recieved = scope.readString() ;
println(recieved + " from serial port"); // show it at the bottom of the processing window
// also do the stuff you want to do when you get things back from the arduino
}

void draw()
{
//get the temp from the serial port
while(scope.available() > 0)
{
tempC = scope.read();

//refresh the background to clear old data
background(123);

//draw the temp rectangle
colorMode(RGB, 160); //use color mode sized for fading
stroke (0);
rect (49,19,22,162);
//fade red and blue within the rectangle
for (int colorIndex = 0; colorIndex <= 160; colorIndex++)
{
stroke(160 - colorIndex, 0, colorIndex);
line(50, colorIndex + 20, 70, colorIndex + 20);
}

//draw graph
stroke(0);
fill(255,255,255);
rect(90,80,100,100);
for (int index = 0; index<100; index++)
{
if(index == 99)
tempHistory[index] = tempC;
else
tempHistory[index] = tempHistory[index + 1];
point(90 + index, 180 - tempHistory[index]);
}

//write reference values
fill(0,0,0);
textFont(font12);
textAlign(RIGHT);
text(“212 F”, 45, 25);
text(“32 F”, 45, 187);

//draw triangle pointer
yDist = int(160 - (160 * (tempC * 0.01)));
stroke(0);
triangle(75, yDist + 20, 85, yDist + 15, 85, yDist + 25);

//write the temp in C and F
fill(0,0,0);
textFont(font24);
textAlign(LEFT);
text(str(int(tempC)) + " C", 115, 37);
tempF = ((tempC*9)/5) + 32;
text(str(int(tempF)) + " F", 115, 65);
}
}
Again, any help would be greatly appreciated!

Although I got them to communicate, for some reason Processing refuses to graph the readings and my temperature sensor readings became totally unreadable. I am also getting the error Null Pointer Exception in my processing code in the line while(scope.available() > 0). I am aware of what Null Pointer Exception is but I don't know how to fix it in my code.

How can they be communicating when you get a NULL pointer exception? Clearly, the NULL pointer is scope, and scope is the serial port that the Arduino is supposed to be connected to. Clearly, it isn't.

You should not be doing serial input in draw(). You should have a serialEvent() function in which you get the serial data. Since you have told the serial instance to buffer data until it gets a CR (or is that LF?), the serialEvent() function will only be called when a complete sentence has arrived.

    tempC = scope.read();

Read the first character. OK. That isn't the whole temperature string, and it certainly isn't a temperature value.