Main Content

writeDigitalPin

R2026b

Write logical value to GPIO output pin

    Description

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

    writeDigitalPin(hwobj,pinNumber,value) sets the logical value of a GPIO pin to 0 or 1.

    If the pin is not configured, this function configures the pin as a GPIO output.

    If the pin is a GPIO input, or if another interface (I2C, Serial, SPI) uses the pin, this method returns an error message.

    example

    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 11 is available. Configure pin 11 as a digital output.

    configurePin(hwobj,11,"DigitalOutput")

    Write a logical value of 1 to pin 11. Setting the logical value of the pin to 1 sets the signal voltage to high.

    writeDigitalPin(hwobj,11,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.

    Logical value of the pin, specified as a scalar.

    Example: 1

    Data Types: double | logical

    Version History

    Introduced in R2021b

    See Also

    Functions

    Objects