Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

  • DEFAULT: the default analog reference of input voltage (VCC) ~3.3V-3.6V
  • INTERNAL1V5: internal analog reference voltage of 1.5V
  • INTERNAL2V5: internal analog reference voltage of 2.5V
  • EXTERNAL: the voltage applied to the VREF pin is used as the reference.



type: which type of reference to use (DEFAULT, INTERNAL1V5, INTERNAL2V5 or EXTERNAL).






After changing the analog reference, the first few readings from analogRead() may not be accurate.



Don’t use anything less than 0V or more than 3.3V for external reference voltage on the VREF pin! If you’re using an external reference on the VREF pin, you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the VREF pin, possibly damaging the microcontroller on your LaunchPad board.

Alternatively, you can connect the external reference voltage to the VREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the VREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the VREF pin.

See also


Reference Home