I'm making a project and I neee to use 2 different references on the same ADMUX. One reference is 0-5V and the other is 0-2.5V. I'm aware that I can use the reference of the Arduino to the 5V sensor. But how I put a 2.5V reference while using the 5V at the same time?
First of all a reference is just a voltage, not a range.
If you use a reference of say 5V than your
analogRead(...) calls will return a 10 bit number where 0 stands for 0V and 1023 stands for 5V.
AREF pin is there for that purpose: feed your 2.5V reference to that pin and use:
when you want to read using the 2.5V reference (0 stands for 0V and 1023 stands for 2.5V in this case), or
when you want to read using the 5V reference (supposing your Arduino is powered by 5V).
Nothing can be done at the exact same time on an Arduino/ATmega328 because it has one single processing unit. In case of analog to digital conversion you can not even perform two conversions on two pins too fast because you have only one ADC which is multiplexed (shared) among all the analog pins.
You have no choice to perform one reading, wait, then perform the other reading. You can change the voltage reference between the two conversions though, but you need to ensure the internal ADC capacitor is properly discharged: if you read a 5V line and then read a 2.5V line without discharging the internal ADC you are more than probably going to always read the maximum value.
How long you will have to wait depends on the impedance of the line you are sampling: higher the impedance, longer the time you have to wait for the ADMUX capacitor to discharge/charge up (Arduino/ATmega328 ADC is a store and sample comparator).