Powering the Arduino and other devices

Hello,

I am currently working with an Arduino and to keep it simple I am controlling a servo motor with a sensor as my analogRead to keep an object at a fixed distance. I want to keep it half the total distance so I've been comparing the analogRead to the integer 512. This all works when I have separate power sources however if I use the same source for everything (Arduino, sensor, H-bridge, Motor) the analogRead is always off by about 100 bits or 1 mm. I've connected the sensors ground to the arduino and tried to make all the grounds common in the circuit. I've connected a power generator to the Arduino's Vin and realized that as soon as I change the Voltage going in (sweeping it from 5.5 to 8V) the arduino reads the analog value differently and the motor starts moving. I found the optimal voltage from the power generator to be 6.07V. This does not make any sense, I thought the Arduino can accept a range of Voltage supplies. I think it could be broken. Ive done a power analysis and there is sufficient current for the whole circuit. Any help would be greatly appreciated.

Thanks,

Nick

See analogReference(). The top value of the analogRead() is dependant on VCC unless you set it to something else. If, for example, you add the following code, your top value becomes 1.1 volts + or - 10%, despite the voltage at VCC.

analogReference(INTERNAL)