Skip to content

ADC_start_conversion

gicking edited this page Feb 8, 2018 · 1 revision

Description

back to Command Reference / Analog-IO

Start ADC measurements for continuous conversion (see ADC_init()). Use measurement channel set via ADC_set_channel().

Notes:

  • Only pins marked as AINx in respective device datasheet have ADC capability.
  • For accurate ADC results configure the respective pin as INPUT via pinMode()
  • ADC_start_conversion() has no effect in single shot mode
  • continuous ADC conversion consumes comparatively high power --> use single-shot mode in energy sensitive applications

Inclusion

  • defined in adc.h
  • not loaded by main_general.h
  • no #define required

Syntax

ADC_start_conversion()

Parameters

  • input:

    • none
  • output:

    • none

Returns

  • Nothing

Example Code

The below code initializes the ADC for continuous measurements of pin AIN5.

#include "main_general.h"
#include "adc.h"

void setup()
{
  ADC_init(ADC_CONTINUOUS);
  ADC_set_channel(5);
  ADC_start_conversion();
}

void loop()
{
  uint16_t result;
  if (ADC_check_conversion_flag()) {
    result = ADC_get_result(5);
    ADC_reset_conversion_flag();
  }
  // ...do something with it
  delay(100);
}

Relevant Tutorial

  • tbd

Notes and Warnings

To avoid damage

  • do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits

See also

Clone this wiki locally