Search wiring.org.co:

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name |

### analogReference()

Examples |
    int inpin = 0;
    int val = 0;

    void setup() {
      // set the analog reference as built-in 2.56Volts
      analogReference(INTERNAL2V56);
      Serial.begin(9600);
    }

    void loop() {
      val = analogRead(inpin);  // read the value of analog pin 0
      Serial.println(val);      // write the value to the serial port
    }
Description | The analogReference() method sets the mode for assigning the voltage used as reference for the analogRead() command, this value will be the maximum voltage used as reference. The default value for 5 Volts boards is 5 Volts. Possible values are: DEFAULT (The default analog reference for 5V boards), INTERNAL1V1 (built-in 1.1Volts. Not available on boards with atmega128 Wiring V1), INTERNAL2V56 (built-in 2.56Volts), INTERNAL (a built-in reference voltage) and EXTERNAL (use as reference the voltage applied to AREF pin in the range 0-5V ONLY). IMPORTANT NOTE: do NOT apply to AREF any voltage out of the 0-5V range. Whenever using an external reference voltage call the analogReference(EXTERNAL) command before calling the analogRead() command, a good place to do it is the setup() method. If the AREF pin is connected to an external source do not use the other reference voltage options in the application, as they will be shorted to the external voltage and cause permanent damage to the microcontroller in the board.
Syntax |
    analogReference(mode)
Parameters |

mode | any of: DEFAULT, INTERNAL1V1, INTERNAL2V56, INTERNAL, EXTERNAL

Usage | Application
Related | analogRead() analogWrite()

Updated on July 07, 2011 11:07:48pm PDT