configurePin - Configure GPIO pin as digital input or digital output - MATLAB (original) (raw)
Configure GPIO pin as digital input or digital output
Since R2021b
Syntax
Description
configurePin([hwobj](#mw%5Fec4d0427-80cc-4d06-9c5b-be8566e30c7e%5Fsep%5Fmw%5Fe4ef5c3f-193d-4700-99b9-936c8ea29966),[pinNumber](#mw%5Fec4d0427-80cc-4d06-9c5b-be8566e30c7e%5Fsep%5Fmw%5Fd0264a27-682e-426b-b785-46d9a0f692df),[mode](#mw%5Fbe1c9485-a84a-4221-b1eb-dfd7b10f09de))
configures the GPIO pinNumber
pin of the Jetson™ board as a digital input or digital output depending on the specifiedmode
.
[pinMode](#mw%5F124b4555-f3d7-4391-b192-718578b107fa) = configurePin([hwobj](#mw%5Fec4d0427-80cc-4d06-9c5b-be8566e30c7e%5Fsep%5Fmw%5Fe4ef5c3f-193d-4700-99b9-936c8ea29966),[pinNumber](#mw%5Fec4d0427-80cc-4d06-9c5b-be8566e30c7e%5Fsep%5Fmw%5Fd0264a27-682e-426b-b785-46d9a0f692df))
returns the current configuration mode of the pin.
Examples
Configure a GPIO
pin as digital input and read its logical value.
Create a connection from MATLAB® to the NVIDIA® Jetson board.
hwobj =
jetson with properties:
DeviceAddress: 'jetson-board-name'
Port: 22
BoardName: 'NVIDIA Jetson TX2'
CUDAVersion: '10.0'
cuDNNVersion: '7.6'
TensorRTVersion: '6.0'
SDLVersion: '1.2'
V4L2Version: '1.14.2-1'
GStreamerVersion: '1.14.5'
OpenCVVersion: '4.1.1'
GPUInfo: [1x1 struct]
WebcamList: []
AvailableDigitalPins: [7 11 12 13 15 16 18 19 21 22 23 24 29 31 32 33 35 36 37 38 40]
The AvailableDigitalPins
property shows the list of available digital GPIO
pins.
Show the location of the GPIO
pins on your device.
Display the AvailableDigitalPins
.
hwobj.AvailableDigitalPins
ans =
7 11 12 13 15 16 18 19
21 22 23 24 29 31 32 33
35 36 37 38 40
Connect your digital device to the first GPIO
pin available, for example GPIO 7
.
Configure pin GPIO 7
as a digital input.
configurePin(hwobj,7,'DigitalInput')
Read the value from pin GPIO 4
.
The logical value of 1
indicates a positive voltage signal on the pin GPIO 7
.
Configure a GPIO
pin as a digital output and write its logical value.
Create a connection from the MATLAB software to the NVIDIA Jetson board.
hwobj =
jetson with properties:
DeviceAddress: 'jetson-board-name'
Port: 22
BoardName: 'NVIDIA Jetson TX2'
CUDAVersion: '10.0'
cuDNNVersion: '7.6'
TensorRTVersion: '6.0'
SDLVersion: '1.2'
V4L2Version: '1.14.2-1'
GStreamerVersion: '1.14.5'
OpenCVVersion: '4.1.1'
GPUInfo: [1x1 struct]
WebcamList: []
AvailableDigitalPins: [7 11 12 13 15 16 18 19 21 22 23 24 29 31 32 33 35 36 37 38 40]
The AvailableDigitalPins
property shows the list of available digital GPIO
pins.
Show the location of the GPIO
pins on your device.
Display the AvailableDigitalPins
.
hwobj.AvailableDigitalPins
ans =
7 11 12 13 15 16 18 19
21 22 23 24 29 31 32 33
35 36 37 38 40
Connect your digital device to an available GPIO
pin, for example GPIO 11
.
Configure pin GPIO 11
as a digital output.
configurePin(hwobj,11,'DigitalOutput')
Write a logical value of 1
to pin GPIO 11
.
writeDigitalPin(hwobj,11,1)
The logical value of 1
sets the signal voltage on pin GPIO 11
to high.
Input Arguments
Connection to a specific NVIDIA hardware board, specified as a jetson object.
GPIO pin number, specified as a scalar. This argument does not accept vectors because the hardware cannot access multiple pins simultaneously.
To get a list of valid pin numbers, use the AvailableDigitalPins
property of the jetson
object. For example, _`hwobj`_.AvailableDigitalPins
.
Example: 12
Data Types: double
Mode used to configure the pin, specified as 'DigitalInput'
,'DigitalOutput'
, or 'Unset'
.
Data Types: char
| string
Output Arguments
Current configuration mode of pin, returned as 'DigitalInput'
,'DigitalOutput'
, or 'Unset'
.
Version History
Introduced in R2021b