analogReference()

Abstract

The analogReferece() sets the reference voltage for analog input. It just sets a global variable.

Source Code

The analogReference() is defined in hardware/arduino/avr/cores/arduino/wiring_analog.c as below.

1
2
3
4
5
6
7
8
9
uint8_t analog_reference = DEFAULT;

void analogReference(uint8_t mode)
{
        // can't actually set the register here because the default setting
        // will connect AVCC and the AREF pin, which would cause a short if
        // there's something connected to AREF.
        analog_reference = mode;
}

The input is mode and its type is uint8_t. The mode can be one of ‘DEFAULT’, ‘INTERNAL’ or ‘EXTERNAL’.

This function stores the mode into the global variable named analog_reference. The analog_reference is used in analogRead().

Version

Arduino AVR Boards 1.8.6

Last Update

March 21, 2023

inserted by FC2 system