5.2. hardware_adc
Library Functions#
To use this library, add following to the C/C++ file,
#include <hardware/adc.h>
and following to the CMakeLists.txt
file.
target_link_libraries(projectName pico_stdlib hardware_gpio hardware_adc)
Following are some of the most commonly used functions for configuring the ADC.
5.2.1. adc_init()
#
Initialize the ADC peripheral on the μC.
5.2.2. adc_gpio_init(uint8_t pinNo)
#
This function initializes a GPIO to work with an ADC input.
Function input
pinNo
can be any GPIO number that supports ADC input, i.e. 26 through 29.
5.2.3. adc_select_input(uint8_t adcIn)
#
This function prepares an ADC input for reading.
Function input
adcIn
can be any ADC input number, i.e. 0 through 5.
5.2.4. uint16_t adc_read()
#
This function makes ADC to read voltage from the input selected using adc_select_input(adcIn)
function.
Function returns an unsigned integer in the range of 0-4095 that corresponds to the measured voltage.