I'm using an LDR (photoresistor) with arduino and i have the following two cases:
Case 1: I connect the input of LDR to Vcc of the arduino, The ground of the LDR to the ground of the arduino and the output of the LDR to A0 (analog pin) of arduino and it reads the values correctly. (like the figure below) Case 2: I make the same exact wiring but instead of taking Vcc from arduino, i take it from an external power supply (also providing 5v) and i connect the ground of the LDR to the ground of the power supply..So input and ground are connected externally and output pin is connected to A0. In this case the arduino reads values incorrectly!
So what's wrong with case 2 why is it not working? Note : in case 2 i measured the voltage between the output of the LDR and the ground is giving a correct value, so why connecting that output to arduino gives incorrect values?
In other words: Why do I need to connect input and ground of LDR to arduino and not to an external power supply?