analogue input problems

HI all
I am fairly new to the world of arduino, although i have tinkered with it a bit, multiwii, ardupilot, etc,

i have decided to undertake my own project,
a voltage meter , thermometer and pwm output with all data shown on lcd screen

the plan is to have a 15v battery pack with a voltage divider hooked to the arduino, the voltage divider will divide 15V to 5V thus making scaling of the real and visible voltages easy to do.

the thermometer is using an lm35.

the pwm will be used to control fan speed.

I have successfully coded all of the parts seperately. i have displayed the required data to the lcd in seperate projects.

BUT here is the conundrum which i need help with. When i try to combine the volt reading and the temp reading, the volt reading affects the temp reading. When the voltage input goes higher, the error on the temp seems to jump up, and if i set the voltage to zero the temp works fine.

does anyone have any ideas to help me ?
the code im using is the following:

#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 12, 7, 8, 9,10);

float tempC;
int tempPin = A1;
int voltpin = A0;
float volt = 0.0;

void setup()
{
lcd.begin(16, 2);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
}

void loop()
{
lcd.clear();
tempC = analogRead(tempPin);
tempC = (5.0 * tempC * 100.0)/1024.0;

volt = analogRead(voltpin);

lcd.setCursor(0, 1);
lcd.print((float)tempC,1);

lcd.setCursor(0, 0);
lcd.print((float)volt,1);
delay(750);
}

try this
#define tempPin 1
#define voltpin 0

instead of

int tempPin = A1;
int voltpin = A0;

Analog readings should not conflict, double check your hardware part. Also what do you exactly mean by combining both readings?

by COMBINE i mean , combine the seperate volt meter project with the seperate Thermometer project,

when i do what you just suggested the voltpin completely dominated the temppin, and as soon as i move the pot (simulating the incoming 0 - 5 v) the temp on the screen displays the same as the volt

the whole thing is on a breadboard, including arduino, BUT, i dont think its a hardware issue, if i comment out the voltpin then it has absolutely no effect on the other,

try this

There's no practical difference between those two implementations.

Can we have a schematic, please?

whats interesting is that i just moved the lm35 to pin a2, updated the code, and had the same problem,

so i added some code to print all three inputs, and all three are affected by the pot, even though there is nothing now connected to A1

I will try to make a schematic, but since i dont have one , or any software im afraid it will be in MSPAINT

okay. As arduino analog input pins are of pretty high impedence so slight touch of electric field can cause erroneous reading(Moreover you are on breadbaord so there is greater chance for this to happen).
Now instead of using very adjacent pins try analog input pins that are farther i-e A0 and A5 .. give it a try!

One way to solve this is to do the reading twice (maybe with slight delay) and then only use the last reading.
The reason is tht the ADC need some time to "recover"

tempC = analogRead(tempPin);           
delay(20);
tempC = analogRead(tempPin);

if i disconect the wiper of the pot from PIN 1 thus eliminating the possibility of a short, i still get a reading of 110 on the PIN1 input, and erroneus TEMP readings of 40 degrees when i know they shoudl be 21

first of all you must check whether your arduino reads analog values correctly or not.. usually i do this with serial monitor. arduino>tools >serial monitor/

Connect two potentiometers to A0 and A1 and check readings using following code.

void setup()
{
Serial.begin(9600);
}

voil loop()
{

int Pin1=analogRead(0);
delay(5);
int Pin2=analogRead(1);

Serial.print("Pin1=");Serial.print(Pin1);

Serial.print("    "); Serial.print("Pin2=");  Serial.println(Pin2);
delay(100);
}

If readings are fine i-e 0 to 1023, there is no problem with controller part it can just sense well its pins.
As far as erroneous temp reading is concerned you may need some further scaling or conversion.

i know that pin 0 reads well, the pot at max returns 1023 and min returns 0 to the lcd,
i can connect it to the other pin to see if the same is true

but i still woudlnt know why the pot on one pin affects the reading on the other,

Again, can we have a schematic, please?

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262906682

AWOL:
Again, can we have a schematic, please?

im just drawing it

heres the schem

Erni:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262906682

thanks, that seems to be the same problem , i will read it through and see what the result is,

although i have a residual reading of 95/1024 on my voltage input pin when nothign is attached , and it goes up according to the temp , when the pot wiper isnt attached, when i attach the wiper the reading goes to 0 when at zero

Erni:
One way to solve this is to do the reading twice (maybe with slight delay) and then only use the last reading.
The reason is tht the ADC need some time to "recover"

tempC = analogRead(tempPin);           

delay(20);
tempC = analogRead(tempPin);

that seems to have improved it greatly. now it is almost compeltely stable regardless of the pot variation ,
thanks