Main Content

Digital Input

Get logical value of digital input pin

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

Library

Simulink Support Package for Arduino® Hardware/Common

  • Digital Input block

Description

Get the logical value of a digital pin on the Arduino hardware:

  • If the logical value of the digital pin is LOW (0 V), the block output emits 0.

  • If the logical value of the digital pin is HIGH (5 V or 3.3 V, depending on the board voltage), the block output emits 1.

The data type of the block output is boolean.

During simulations without the hardware, this block emits zeroes.

Parameters

Pin number

Enter the number of the digital pin.

Do not assign the same pin number for different types of blocks as this may cause resource management conflicts.

Click View pin map to open the Arduino Pin Mapping table.

To know how to assign pins or to know about the fixed pins for the block, see Pin Mapping for Arduino Timer Independent Blocks.

Sample time

Specify how often this block reads the pin value, in seconds. Enter a value greater than zero. This value defaults to a sample time of 0.1 second.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.