Calculating Unknown Resistor with Arduino

Connecting the external 5volt supply to Aref could be dangerous.
Better leave Aref as it is (default), and power the Arduino from the external 5volt supply (on the 5volt pin).
Leo..