Main Content

configurePinResource

Set resource owner and mode of pin

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

Description

mode = configurePinResource(arduinoObj, pin) returns the specified mode of pin.

configurePinResource(arduinoObj, pin, resourceOwner, mode, forceConfig) configures the mode of pin to the specified mode and the specified resourceOwner. You can optionally force this configuration on the pin using forceConfig.

example

Examples

collapse all

Change the resource owner and mode of the digital pin 'D11' on an Arduino® Uno to I2C.

Query pins current mode.

arduinoObj = obj.Parent;
mode = configurePinResource(arduinoObj, 'D11')
mode = 
 'SPI'

Change the resource owner to 'i2cdev' and mode to 'I2C'.

configurePinResource(a, 'A4', 'I2C', 'I2C')

Input Arguments

collapse all

Arduino object, specified as an object that is an internal variable called from within classes that derive from matlabshared.addon.LibraryBase.

Pin on Arduino hardware, specified as a character vector.

Owner of pin resource, specified as a character vector.

Mode of terminal, specified as a character vector. Possible mode values are:

  • 'DigitalInput'

  • 'DigitalOutput'

  • 'AnalogInput'

  • 'PWM'

  • 'I2C'

  • Interrupt: specify pin in interrupt mode to be used in rotaryEncoder

  • 'Servo'

  • 'Unset'

  • 'SPI'

  • Tone: specify pin to use for playTone

  • Ultrasonic: specify pin to used with ultrasonic sensor

  • 'Reserved'

  • 'Pullup'

Specify if mode change on the pin is forced. Specify 'true' to force the change and 'false' to not force the change. Use this when the current pin mode is not compatible with the new pin mode. Compatible modes you can change without forcing the configuration include:

  • 'unset' to any mode

  • 'Reserved' to any mode

  • 'DigitalOutput' to 'PWM'

  • 'PWM' to 'DigitalOutput'

  • 'DigitalInput' to 'AnalogInput'

  • 'AnalogInput' to 'DigitalInput'

Output Arguments

collapse all

Mode of specified terminal, returned as a character vector. Possible output mode values are:

  • 'DigitalInput'

  • 'DigitalOutput'

  • 'AnalogInput'

  • 'PWM'

  • 'I2C'

  • 'Servo'

  • 'Unset'

  • 'SPI'

  • 'Reserved'

  • 'Pullup'

Version History

Introduced in R2015b