Using tempreature to control servo with a twist

hi I need help
I buisy with a project to automate my smoker
I want to use calculated diffrance of temp set ( I got a POT to adjust heat where I want it) and smoker temp sensor..
I got a problem where it goes thou it loop and I cant read my servo position from previous loop

I want the program to do this

iam not gona write the whole program just the part iam stuck

int degreesC = smokers temp sensor
int setDegC = temp (potentionmeter)
int smokePos = i cant seem to get the position of servo or get value where i told the servo to write to in previous loop to add 1 deg in new loop

if (degree < setDegC)
servoSmoke.write(smokePos++)

else
servoSmoke.write(smokePos--)

please let me know what iam missing ..

i know i can map temp to get where my servo can be set but i dont want the flap to be at a fixed point at a temp i want it to always open if the temp climbs and once its over temp it will close 1 deg between loops,

Why are you not just using a global variable to store the position of the servo?

Danois90:
Why are you not just using a global variable to store the position of the servo?

hi thanks WORKING great but maybe you can advice me on another problem..

if I got a value x.. is there a way to make x between 0-180 so if my program ses -- it wint go into the neg and if it ses ++ it wont go above 180

if (x<0) x = 0;
else if (x>180) x = 180;

evanmars:

if (x<0) x = 0;

else if (x>180) x = 180;

thanks works perfect