chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko

AnalogRead

  1. Synopsis

  2. Description

  3. Return Value

  4. Conforming To

  5. Example

  6. See Also

Synopsis

int analogRead(uint8_t pin);

Description

The analogRead() function performs an Analog-to-Digital Conversion of a voltage on an analog input pin. The sampled voltage is converted to a numeric value at the native resolution of the ADC module of the main MCU. Typically that is a 10-bit resolution yielding a 0-1023 output value. The pin may be either the absolute I/O pin number of the analog pin, a logical analog pin number starting from 0 (only supported on some boards), or the symbolic name Ax where x is the number of the analog pin as depicted on the board.

Return Value

The voltage represented as a numeric value at the resolution of the ADC module. For a 10-bit module that yields 1024 possible steps, where 0 represents 0V and 1023 represents the analog reference voltage (see: analogReference()).

Conforming To

The analogRead() function conforms to the Arduino 1.6.x specification.

Example

 int val = analogRead(2);

See Also

analogReference(), analogWrite()