Go Down

Topic: Thermostat code (Read 2 times) previous topic - next topic

lloyddean

Post the post change code.

Dadu


Quote
Could it be due to a little short I made for mistake the other day? It lasted 1-2 seconds though,and everything else works fine anyway,so I actually don't think it's that..but I just can't figure out what's not working.

Are all the analog pins affected? If so, it's time to go shopping.

Yup they're all affected in the same way..even if I remove the pot reading code and just get the temperature itself,but still rotate the pot it goes nut..dammit!

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:
Code: [Select]

 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

Code: [Select]
 
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.

Dadu

#8
Feb 14, 2013, 09:23 pm Last Edit: Feb 14, 2013, 09:49 pm by Dadu Reason: 1

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:
Code: [Select]

 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

Code: [Select]
 
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 :/
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?  :smiley-roll-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?

PaulS

Quote
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?

Most likely just a new chip (with bootloader already installed).

Go Up