Thermostat code

MaJiG:
You are reading a pot that reads from 0V to 5V. The Arduino's A2D reads the voltage in 1024 steps, thus each step represents 5/1024 ~= 5mV
This maps to 0 = 0oC and 1023 = 30oC.

The LM35 reads 10mV for each degree C, thus 250mV corresponds 25oC. This means the highest reading should be no more than 300mV.
300mV will be a reading of about 60.

I would read in the raw A2D reading and then use the map() function to compare apples to apples.

So something like this:

  fine = analogRead(5); //read the raw temp data

fine = map(fine, 0, 1023, 0, 30); // adjust the raw reading to a scale from 0 to 30




then later 



int temp;

temp = analogRead(0); //read the actual raw temp.  should be 0 to 60 for the 0 to 30[sup]o[/sup]C range
temp /= 2;                 // adjust a2d to our range




I think that works. Let me know if I'm crazy.

I don't think you're crazy,I'd rather say I'm just unlucky ,'cause it still doesn't work :confused:
Anyway just to let you know,the short I was talking about was that I reversed the +Vin and Gnd pins of the lm35 ,causing it to incredibly overheat ,I even burned my finger removing it. Strangely it still works fine,but if i put any combination of analog pins with the sensor and the pot they just affect each other..what did I do? :cold_sweat:

EDIT: And in case I fried the Arduino,where is the problem most likely located in? Should I get a brand new board,or just a new ATMega chip?