I connect analog output to analog pin A0 and analogRead that pin. The value shown is around 400-500, is this correct? Isnt the value range between 0-1023?
0 for 0V, 1023 for 5V. Approximately 512 for a 50% PWM analog output, say with analogWrite (pinX, 127);
analogWrite outputs a 0/5V signal, and not a smooth analog signal.
This is related to your question about your pH sensor?
An adc reads a voltage and turns it into a number.
Do look up the workings of an adc for better understanding of what you are working with.