Aref on Vin instead 5V Out



  • I’m working on a project with an Arduino Mega which includes multiple potentiometers ranging from 0 to 10kOhm.
  • The board is powered using the onboard USB-socket.
  • I printed the pcb already and I do not intend to change any of the wiring.

Instead of connecting the 5V, Gnd and the corresponding Ain to the potentiometer, I connected it using the Vin, Gnd and the Ain. There is no way to get a wire from the 5V to the Aref pin.
I believe this causes the analog values to jump a lot. On the unprocessed signal I can read values ranging [0;12] in the 0 position of the potentiometer.

Signal processing this far:
- Instead of reading it with 10Bit resolution, I divided it by 8 (actually I mapped the actual range [0; 890] => [0;127]).
- This value is being averaged with 10 values using the smooting method.
Is there a way to use vin as the aref (if it isn’t yet)?
If the jumping is normal, how do I best eliminate the jumping, when accuracy and reactivity (speed) is important?
Thanks for your help!

Aref can be any voltage less than or equal to the voltage powering the chip. In most Arduinos this is 5V. You will damage the chip if you connect any higher voltage to Aref. Vin is higher (7-12V probably) so you can’t use that. It also can’t be negative.

For reading potentiometers, don’t change Aref. It only makes sense to do that for certain temperature sensors or other low-voltage sensors. Just use the standard 5V and connect all your potentiometers to the SAME 5v.

V-in is the input of the 5volt regulator.

Powering the pots from the V-in pin is bad if you're on USB supply, because current is flowing backwards through the regulator. The regulator might not like this, and you have less than 5volt on the pots (less A/D values).

If you're on external power (DC socket or V-in), then voltage on the pot is just that voltage.
You will damage the analogue inputs when you turn the pots fully up.
Same goes for Aref. If Aref is more than VCC, you will damage the Aref pin.
You will also damage the Aref pin if voltage on that pin is less than VCC and you didn't set Aref to external.

Power the pots from the 5volt pin, and use default Aref (do nothing with Aref in code).
That's the only way to get a stable readout.

Not hard to cut a small piece out of a circuit board track with a scalpel, and re-route the track with a piece of wire.
We all had to learn from our mistakes.