Graphing temperature with processing problem!

Alright So my current set up for my Arduino Duemilanove is 2 buttons 3 LED a Fan and a Temp sensor my code is set to run the speed of the fan at a certain speed depending on the temp i have a low and high set point. these two set points could be changed by using the buttons but for some odd reason every time my temp either gets too hot or i lower my set point too low my arduino stops reading values and my graph stops giving me data >:(

I’m sure the problem is only with the Arduino code so I’m only posting that THX

int sensorPin0 = 0, ledPin = 9, sensorPin = 3, x = 0, press=0, press2=0, sensorPin2=10, Th=25,Tl=23;
double t;

void setup()
{
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
}

void loop()
{ int reading= digitalRead(sensorPin);
while(reading>0)
{
reading= digitalRead(sensorPin);
press++;
delay(100);
}
if (press>1){x++;
press=0;}

int reading2= digitalRead(sensorPin2);
while(reading2>0)
{
reading2= digitalRead(sensorPin2);
press2++;
delay(100);
}
if (press2>1){x–;
press2 = 0;}

int reading0 = analogRead(sensorPin0);
float voltage = reading0 * 5.0 / 1024;
float temperatureC = (voltage - 0.5) * 100 ;
Th=27+x;
Tl=23+x;
if (temperatureC > (Th))
{t=255;
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
}
if (temperatureC < (Th) && temperatureC > (Tl))
{t=100;
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
}
if (temperatureC <=(Tl))
{t=0;
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
}
for (int i=0; i<=t; i++)
{
analogWrite(ledPin, i);
}
Serial.println(Th);
Serial.println(Tl);
Serial.println(temperatureC);
Serial.println(t);
}

So my current set up for my Arduino Duemilanove is 2 buttons 3 LED a Fan and a Temp sensor

int sensorPin0 = 0, ledPin = 9, sensorPin = 3, x = 0, press=0, press2=0, sensorPin2=10, Th=25,Tl=23;

Is that sensor connected to sensorPin, sensorPin0, or sensorPin2? Why not actually use meaningful names?

 pinMode(7, OUTPUT);
 pinMode(6, OUTPUT);
 pinMode(5, OUTPUT);

Why don’t these pins get meaningful names?

int reading= digitalRead(sensorPin);

Which sensor is this that is being read?

 while(reading>0)
 {
   reading= digitalRead(sensorPin);
   press++;
   delay(100);
 }
 if (press>1){x++;
 press=0;}

No matter how long the switch (I’m assuming that the “sensor” is really a switch) is held down, x is only incremented once. Is that what you want to have happen?

my code is set to run the speed of the fan at a certain speed depending on the temp

The only pin that has a non-constant output is the one in the variable named ledPin. Do you have an LED or a fan connected to that pin?

every time my temp either gets too hot or i lower my set point too low my arduino stops reading values and my graph stops giving me data

So, every time pin 7 is set HIGH, the program stops outputting serial data. What is connected to pin 7?

but for some odd reason

It is not an odd reason. It is a computer program it is doing exactly what you told it to. The fact that you told it to do the wrong thing is not the computers fault or an odd or random event but entirely down to you.

Once you get that in your head you might go some way towards solving your problem.

Thx i have rewrote my code now with better meaning full language and it turned out that it was a resistor that had too low of a resistance so my program got crazy when the pin would send out a value of 255 :)