Thanks for the reply but my understanding is that analogread(0) and analogread(A0) are the same. I thought A0 was only necessary for digital operations on analog pins.
Okay, I can't see anything else that may be wrong... which Arduino board are you using and which IDE version?
Does putting the analog Read before the LCD in the sketch do anything odd?
Try a different older IDE as there are some incompatibilities with some libraries with the newer 1.6.X IDE.
Problems with the newer IDE and LCD library has been noted by someone in another thread but no one seems to have been interested in investigating it...
I don't have access to any Arduino hardware at the moment, but I will try your sketch with an old LCD I have and see if I can track down the root cause. In which case I will update this thread.
I have a 16x2 display and when I hooked that up it behaved fine including analogread(A0).
However, with exactly the same pin connections on my 8x2 I get the analogread problem.
I can't understand this as supposedly it uses the same LCD controller chip. Despite that, it doesn't seem to be compatible unless there is a problem with the Liquidcrystal library that isn't happy with an 8x2 display
I will contact the people I bought the 8x2 display from
How odd. I suspect the display is fine but the library is doing something strange when an 8 x2 is called up. As the controller is common you could try 8x2 size settings in the sketch with the 16x2 LCD attached and see what happens.
There is absolutely no difference in how the library deals with the 8x2 and the 16x2 devices. The first parameter is not used and the second is only checked to see if it is > 1. (The fact that the first parameter is not used is the reason why the library does not deal with 16x4 devices properly, but that is another issue entirely.)
I have no explanation for the phenomena that you are experiencing since, once you have displayed information on the LCD, it remains there until that information is overwritten. Reading information from an analog pin should have no effect on the LCD.
I suggest that you try using the Arduino IDE rather than by the supposedly 'fully compatible' Visual Micro and see if you get the same result.
I wonder if the information is there but somehow the display has been blanked. I'm using fixed resistors instead of a potentiometer for the contrast. I'll have a play with that
Since your loop contains only that one statement you are doing that analog read over and over again really quickly. This shouldn't affect the LCD, but apparently it is. What happens when you put a delay in that loop?
Actually, the trimmer does not need 5V at all. It will actually work better with that end unconnected. A 2k2 variable resistor between VO and ground will work even more conveniently.
Now - I KNOW that isn't what its there for but it seemed to be providing a convenient source of 5V.
AREF is an input pin, it expects to receive a voltage not to supply one.
I wonder how long this would have taken to solve if we had been provided with sufficient information. Data sheets for the displays and a photograph of the setup come to mind.