I've test the LM35 with LCD and 3dig pin as a output for cold medium and high temp in C deg which is working great . right now in my new project I have 11 outputs (A0 to A3 modified as the output and A4 as a input) . Switching on/off any pins will change the analog value of pin A4 which is connected to the LM35. so the reading is not correct. I have 5V external regulated voltage source for LM35 and both arduino and voltage source are grounded(arduino is power up with USB). when i measure the output voltage of the LM35 it is 315mv which is being read as 63 in arduino. when i switch on any pin, the arduino read will be changed based on how many switches are on but the LM35 output voltage is as same as before. I've connected the sensor directly and there is no resistor or anything else and the board is UNO. I would be glade if anyone could help me to solve this problem. Thanks.
Could be a noise problem on the controller. I would try to read the analog input twice, ignore the first measurement and take the second one.
ashkan1637: Switching on/off any pins will change the analog value of pin A4 which is connected to the LM35. so the reading is not correct.
Do you really mean any pins, or do you mean pins that have loads connected to them?
There are two reasons why switching pins that have loads connected to them may change the reading:
You are using the same ground pin to connect the LM35 and the power supply, or the LM35 and the load(s). Don't do that, because changes in the microcontroller or load current will induce a voltage drop across the shared ground wire due to its resistance and inductance, which will be fed through the LM35 to the analog input. Always dedicate one Arduino ground pin as analog ground, and don't use that ground pin to connect anything apart from analog sensors.
Even a regulated supply may not be very well regulated, depending on what sort of regulator it uses. Variations in the load current can cause the voltage to vary a little, and if you are using the 5V supply as the analog reference (the default), then those variations will affect the analog readings. USB power can be particularly bad. Unless the 5V supply comes from a good linear regulator, consider using the 3.3V pin to provide the analog reference, or use the internal 1.1V reference.
THANKS a lot dc42. The problem was the first one as i used same ground for everything. pins are just load pins . now its working great and there are no more noise using 5V pin. THANKS again.
dear Elektrix. Thanks a lot for your response , dc42 helps me to solve the problem but your suggestion is grate for having a better measurement. will consider it . thanks.