configureDigitalPin
Description
configureDigitalPin(
sets the specified controller
,pin
,mode
)pin
on controller
to the
specified mode
. Set a pin to input mode to read its logic level value
and set it to output mode to send it a logic level value.
Examples
Set Digital Pin Mode on NI USB-845x Controller
Connect to an NI™ USB-845x Interface Device and configure the digital I/O pins on it.
Connect to the NI USB-845x using its serial number. In this example, the NI USB-845x controller board that is connected to the computer has the serial
number 01F26E0A
.
controller = ni845x("01F26E0A");
View the available digital I/O (DIO) pins on the controller and their respective pin
modes by using the DigitalPinModes
property.
controller.DigitalPinModes
ans = 8×2 table Pin Mode ______ _______ "P0.0" "input" "P0.1" "input" "P0.2" "input" "P0.3" "input" "P0.4" "input" "P0.5" "input" "P0.6" "input" "P0.7" "input"
Configure the DIO(0), P0.0, pin as output.
configureDigitalPin(controller,"P0.0","output")
Since pin P0.0 is an output pin, you can now send it a logic high level using
writeDigitalPin
. Since the other pins are input pins, you can
read their logic level using readDigitalPin
.
Input Arguments
controller
— Controller connection
aardvark
object | ni845x
object
Controller connection, specified as an aardvark
object or
ni845x
object.
Example: configureDigitalPin(controller,pin,mode)
sets the pin
mode for the Aardvark™ or NI USB-845x controller controller
.
pin
— Digital I/O pin number
character vector | string scalar
Digital I/O pin number to configure as input or output, specified as a character
vector or string scalar. Possible values are the pin numbers returned by
controller.AvailableDigitalPins
.
Example: configureDigitalPin(controller,"Pin1",mode)
sets the mode
for the pin Pin1
on the Aardvark
controller.
Data Types: char
| string
mode
— Pin mode
"input"
| "output"
Pin mode, specified as "input"
or "output"
.
You can read logic values from input pins using readDigitalPin
and
send logic level values to output pins using
writeDigitalPin
.
Example: configureDigitalPin(controller,pin,"output")
sets the pin
mode to output for the Aardvark or NI USB-845x controller.
Data Types: char
| string
Version History
Introduced in R2023a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)