Main Content

Digital Input

Get logical state of digital input pin on Arduino

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

  • Arduino Digital Input block

Libraries:
Simulink Support Package for Arduino Hardware / Common

Description

Use the Digital Input block to read and output the logical state of the digital pins on your Arduino® board.

During the external mode simulation, the block outputs the simulation results returned from the executable running on the target hardware. During simulation in all other modes, the block outputs zeroes.

Ports

Output

expand all

The block outputs the logical state of the digital pin on the Arduino board that you specify in the Pin number parameter.

  • 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.

Data Types: Boolean

Parameters

expand all

Enter the Arduino board digital input pin number. To open the Arduino pin mapping table, click View pin map. For more information on how to assign pins for the Digital Input block, see Pin Mapping for Arduino Timer-Independent Blocks.

Set the mode of the Arduino board digital pin.

  • Default — Select this mode to set the Arduino board digital pin to the default mode. This mode sets the pin in an high-impedance state. In this mode, the pin can detect the voltage applied to it, either HIGH or LOW.

  • Input Pullup — Select this mode to set the Arduino board digital pin to the input pullup mode and activate the internal pull-up resistor. The pull-up resistor ensures that the pin reads a HIGH state by default when an external signal is not applied.

Specify how often this block reads the pin value, in seconds. Enter a value greater than zero.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns. When you specify this parameter as –1, Simulink® determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2012a