help for temp sensor and servo

hi i made a program that the servo sweeps and when it dedect a high temp the servo stops but it wont stop.
im new at programming.
this is a piece of the code.
// IF ELSE
if (Temp3 < 30) { // If the temp is too low it sweeps

digitalWrite(ledPin, LOW); // sets the LED off
servo_sweep();


}else{ // If the temp is too high the led turns on

digitalWrite(ledPin, HIGH); // sets the LED on

} //END OF IF STATEMENT
delay(100);
}
void servo_sweep(){
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

thx.

Your servo sweep takes nearly five and half seconds - how rapidly does the temperature change?
Please post ALL your code,and use the # icon on the editor's toolbar.

the temp changes when the sweep is over but i dont know why its doing that.

dont mind the ping in the code thats for later.

thx.

test_17_07.pde (3.48 KB)

dont mind the ping in the code thats for later

There isn't a ping in the code, so how could I mind it.

the temp changes when the sweep is over but i dont know why its doing that

Because that's the only time you're looking at it?

with ping i mean the ping sensor.

en how do i look always at the temp?

thx.

nobody?

try to loose your delay statements.

when you use "delay" you basically put your arduino to sleep. It simply does nothing (as in, it will not read temperature etc.)

take a look at the "blink without delay" tutorial (its also an example sketch in your arduino ide)

p

(only looked at your code snippet. have not seen the full code)

thx got it working.