Help CenterHelp Center
Read logical value from GPIO input pin
Since R2021b
pinvalue = readDigitalPin(hwobj,pinNumber)
example
pinvalue = readDigitalPin(hwobj,pinNumber) returns the logical value of a digital pin.
pinvalue
hwobj
pinNumber
If the pin is not configured, this function configures the pin as a GPIO input.
If the pin is a GPIO output, or if another interface (I2C, Serial, SPI) uses the pin, this method returns an error message.
collapse all
Configure a GPIO pin as digital input and read its logical value.
GPIO
Create a connection from MATLAB® to the NVIDIA® Jetson™ board.
hwobj = jetson
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.
AvailableDigitalPins
Show the location of all the GPIO pins on your device.
showPins(hwobj)
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.
GPIO 7
Configure pin GPIO 7 as a digital input.
configurePin(hwobj,7,'DigitalInput')
Read the value from pin GPIO 4.
GPIO 4
readDigitalPin(hwobj,7)
ans = 1
The logical value of 1 indicates a positive voltage signal on the pin GPIO 7.
1
Connection to a specific NVIDIA hardware board, specified as a jetson object.
jetson
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
12
Data Types: double
double
0
Logical value of the pin, returned as a scalar.
Introduced in R2021b
configurePin
showPins
writeDigitalPin
drive
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office