Arduino_AdvancedAnalog - AdvancedADC.begin()

Initializes and configures the ADC with the specified parameters. To reconfigure the ADC, stop() must be called first.

Syntax

adc0.begin(resolution, sample_rate, n_samples, n_buffers)

Parameters

  • enum - resolution the sampling resolution (can be 8, 10, 12, 14 or 16 bits).
    • AN_RESOLUTION_8
    • AN_RESOLUTION_10
    • AN_RESOLUTION_12
    • AN_RESOLUTION_14
    • AN_RESOLUTION_16
  • int - sample_rate - the sampling rate / frequency in Hertz, e.g. 16000.
  • int - n_samples - the number of samples per sample buffer. See SampleBuffer for more details.
  • int - n_buffers - the number of sample buffers in the queue. See SampleBuffer for more details.
  • bool - start - if true (the default) the ADC will start sampling immediately, otherwise start() can be called later to start the ADC.
  • enum - sample_time - the sampling time in cycles (the default is 8.5 cycles).
    • AN_ADC_SAMPLETIME_1_5
    • AN_ADC_SAMPLETIME_2_5
    • AN_ADC_SAMPLETIME_8_5
    • AN_ADC_SAMPLETIME_16_5
    • AN_ADC_SAMPLETIME_32_5
    • AN_ADC_SAMPLETIME_64_5
    • AN_ADC_SAMPLETIME_387_5
    • AN_ADC_SAMPLETIME_810_5

Returns

1 on success, 0 on failure.