Jimster:
I'm just using an atmega 328 on a breadboard, there is nothing connected to pin21 Aref, is this where I've gone wrong?
No, nothing should wire to the pin unless you are using a analogReference(EXTERNAL) command in your sketch. Some recommend wiring a .1 ufd cap from Aref pin to ground for added noise filtering.
Check all your wiring between sensor and arduino board. A link to your sensor might be useful.
Also check your breadboard wiring and be sure you are using proper bypass capacitors on the AVR Vcc and Avcc pins.
Lefty
The sensor is a load cell, I've also replicated the problem using a diode between 5v and analogue input 3. When tested with a digital multi meter it shows around 4.2v but stil 1023 on the serial monitor. There is nothing else in my code, the complete code is above.
Some recommend wiring a .1 ufd cap from Aref pin to ground for added noise filtering.
Yes I would, even up to 1uF.
Also check the decoupling on the supply pins and also make sure you have both the analogue and digital supplies connected on the bread board.
For extra precision wire an inductor between analogue and digital power pins, with a cap to ground on both and feed the power into the digital pin.
Sorry to be lame, but what do you mean by coupling?
Maybe I should start from the beginning, can anyone point me in the direction of a diagram of the minimum components for an arduino where I can read analogue voltages accurately?
Jimster:
I've also replicated the problem using a diode between 5v and analogue input 3. When tested with a digital multi meter it shows around 4.2v but stil 1023 on the serial monitor.
As well as a diode, you need a pulldown resistor connected between the pin and ground. When the DMM is connected, the DMM acts as a pulldown resistor. Disconnect it and the pin will probably float up to 5V.
Check that the Aref pin isn't shorted to anything, and that Avcc is connected to +5V.