Hauptinhalt

configurePin

R2026b

Configure GPIO pin as digital input or output

    Description

    Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

    configurePin(hwobj,pinNumber,mode) configures the GPIO pinNumber pin of the Jetson™ board as a digital input or digital output depending on the specified mode.

    example

    pinMode = configurePin(hwobj,pinNumber) returns the current configuration mode of the pin.

    Examples

    collapse all

    Create a connection from MATLAB® to the NVIDIA® Jetson board.

    hwobj = jetson;
    

    To display the available digital GPIO pins on the board, access the AvailableDigitalPins property of the jetson object. The output depends on your specific hardware board.

    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. In this example, the AvailableDigitalPins property shows pin 7 is available. Configure pin 7 as a digital input.

    configurePin(hwobj,7,"DigitalInput")
    

    Read the value from pin 7. In this example, the readDigitalPin function returns 1, which indicates a positive voltage signal on the pin.

    value = readDigitalPin(hwobj,7)
    
    value =
    
      1

    Input Arguments

    collapse all

    Connection to a specific NVIDIA hardware board, specified as a jetson object.

    GPIO pin number, specified as an integer.

    To get a list of valid pin numbers, use the AvailableDigitalPins property of the jetson object. To view a diagram of the pins for your Jetson board, use the showPins function.

    Mode used to configure the pin, specified as "DigitalInput", "DigitalOutput", or "Unset".

    Data Types: char | string

    Output Arguments

    collapse all

    Current configuration mode of pin, returned as 'DigitalInput', 'DigitalOutput', or 'Unset'.

    Version History

    Introduced in R2021b

    See Also

    Functions

    Objects