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);
}