ADC 0 reading correctly only with oscilloscope

I have a problem that whenever I am reading from ADC pin 0, it reads correctly if my oscilloscope is connected to the ADC pin too. Otherwise it gives me double of the input. I tried uno an Mega2560. I happens only with pin A0. I am giving my input from function generator. Why so?

I am giving my input from function generator.

I can guess, but details would be better.

Schematics are required for this. Please provide.

Psychic Mike says:- it is the ground from your scope that is making it work. Try connecting a wire from the ground on your signal generator to the arduino's ground. 8)

Ground of Arduino, Oscilloscope and Signal generator are always connected together. But when I connect oscilloscope's input at ADC input pin (which is connected to signal generator output), it reads correct. If I disconnect oscilloscope input (not the ground), arduino read 2*real value.

Vague supposition:

There is a decoupling capacitor on the output of the function generator which removes the internal DC offset from the signal. That requires a suitable load on the output to allow the capacitor to loose its charge and operate correctly - without it there will be a residual charge in the capacitor giving an offset to the value read. When you add the oscilloscope it provides a resistance across the output that is lower than the resistance of the ADC and makes the cap work right.

Try adding a resistor in parallel with the ADC input (ADC->GND), say 100K?, and see if that helps.