Main Content

Analog Input

Read ADC register value after ADC conversion at the analog pin of Arduino SAMD21 core

Since R2023b

  • Arduino Analog Input SAMD Icon

Libraries:
Simulink Support Package for Arduino Hardware / Advanced / SAMD

Description

Use the Analog Input block to read the value from an ADC register after analog to digital conversion on the Arduino® SAMD21 analog pin. You can use the block to read up to three analog voltage outputs simultaneously.

Use the block inside a downstream function call subsystem that executes the ADC conversion operation based on an interrupt service routine (ISR) trigger. You specify the ISR trigger using an Hardware Interrupt block.

Note

The Analog Input block supports C/C++ code generation. This feature allows you to generate C and C++ code using Embedded Coder®.

Supported Arduino Boards

  • Arduino MKR 1000

  • Arduino MKR ZERO

  • Arduino MKR Wi-Fi® 1010

  • Arduino Nano 33 IoT

Ports

Output

expand all

The block outputs the digitally converted voltage data that is received on the analog input pin of the Arduino board. The number of output ports depends on the number of analog input pins you specify in the Number of analog input pins parameter. For example, if you set the Number of analog input pins parameter to 3, the block enables three output ports with port names ADC_Ch1(A0), ADC_Ch2(A1), and ADC_Ch3(A2).

Data Types: double

Parameters

expand all

Select the number of inputs for analog to digital conversion.

Enter the Arduino board analog input pin number. To open the Arduino pin mapping table, click View pin map. To know how to assign pins for the Analog Input block, see Pin Mapping for Arduino Timer Independent Blocks.

The number of Pin Number parameters depends on the number of analog input pins you specify in the Number of analog input pins parameter. For example, if you set the Number of analog input pins parameter to 3, the block enables the Pin number 2 and Pin number 3 parameters. You can enter the analog pin numbers for the Arduino board accordingly.

Select this option to generate an interrupt after the analog voltage at the pin of the Arduino hardware is converted to its equivalent digital voltage.

Version History

Introduced in R2023b