configureDigitalPin
Configure GPIO pin as input or output
Add-On Required: This feature requires the MATLAB Support Package for BeagleBone Black Hardware add-on.
Description
Examples
You can configure a GPIO pin as digital input and read its logical value.
Create a connection from the MATLAB® software to the BeagleBone® Black hardware.
bbb = beaglebone
bbb = beaglebone with properties: DeviceAddress: '192.168.7.2' BoardName: 'BeagleBone Black Rev 00C0' AvailableLEDs: {'USR0' 'USR1' 'USR2' 'USR3'} AvailableDigitalPins: {1x29 cell} AvailableAnalogPins: {'AIN0' 'AIN1' 'AIN2' 'AIN3' 'AIN4' 'AIN5' 'AIN6'} AvailablePWMPins: {} AvailableSPIChannels: {} AvailableI2CBuses: {'i2c-1'} AvailableSerialPorts: {} AvailableWebcams: {}
The AvailableDigitalPins
property shows the list of available digital
pins.
Redisplay AvailableDigitalPins
.
bbb.AvailableDigitalPins
ans = Columns 1 through 5 'P8_7' 'P8_8' 'P8_9' 'P8_10' 'P8_11' Columns 6 through 10 'P8_12' 'P8_13' 'P8_14' 'P8_15' 'P8_16' Columns 11 through 15 'P8_17' 'P8_18' 'P8_19' 'P8_26' 'P9_11' Columns 16 through 20 'P9_12' 'P9_13' 'P9_14' 'P9_15' 'P9_16' Columns 21 through 25 'P9_21' 'P9_22' 'P9_23' 'P9_24' 'P9_26' Columns 26 through 29 'P9_27' 'P9_30' 'P9_41' 'P9_42'
Show the physical location of GPIO 60.
showPins(bbb)
The corresponding pin identifier is 'P9_12'
.
Connect the digital device that you are using to 'P9_12'
.
Check whether 'P9_12'
is already configured.
configureDigitalPin(bbb,'P9_12'
)
ans = unset
Configure 'P9_12'
as a digital input.
configureDigitalPin(bbb,'P9_12'
,'input')
Read the value from pin 'P9_12'
.
readDigitalPin(bbb,'P9_12'
)
ans = 1
You can configure a pin as a digital output and write its logical value.
Create a connection from the MATLAB software to the BeagleBone Black hardware.
bbb = beaglebone
bbb = beaglebone with properties: DeviceAddress: '192.168.7.2' BoardName: 'BeagleBone Black Rev 00C0' AvailableLEDs: {'USR0' 'USR1' 'USR2' 'USR3'} AvailableDigitalPins: {1x29 cell} AvailableAnalogPins: {'AIN0' 'AIN1' 'AIN2' 'AIN3' 'AIN4' 'AIN5' 'AIN6'} AvailablePWMPins: {} AvailableSPIChannels: {} AvailableI2CBuses: {'i2c-1'} AvailableSerialPorts: {} AvailableWebcams: {}
The AvailableDigitalPins
property shows the list of available
digital pins.
Redisplay AvailableDigitalPins
.
bbb.AvailableDigitalPins
ans = Columns 1 through 5 'P8_7' 'P8_8' 'P8_9' 'P8_10' 'P8_11' Columns 6 through 10 'P8_12' 'P8_13' 'P8_14' 'P8_15' 'P8_16' Columns 11 through 15 'P8_17' 'P8_18' 'P8_19' 'P8_26' 'P9_11' Columns 16 through 20 'P9_12' 'P9_13' 'P9_14' 'P9_15' 'P9_16' Columns 21 through 25 'P9_21' 'P9_22' 'P9_23' 'P9_24' 'P9_26' Columns 26 through 29 'P9_27' 'P9_30' 'P9_41' 'P9_42'
Show the location of GPIO 48.
showPins(bbb)
The corresponding pin identifier is 'P9_15'
.
Connect the digital device that you are using to 'P9_15'
.
Configure pin 'P9_15'
as a digital output.
configureDigitalPin(bbb,'P9_15'
,'output')
Write a logical value of 1 to pin 'P9_15'
.
writeDigitalPin(bbb,'P9_15'
,1)
Input Arguments
BeagleBone Black connection created using beaglebone
, specified as an
object.
GPIO pin identifier, specified as a character vector. This argument does not accept vectors because the board cannot access multiple pins simultaneously.
To get a list of valid pin identifiers, enter
.bbb
.AvailableDigitalPins
Example: P8_12
Data Types: double
Pin direction, specified as a character vector. Configures the pin as an input or an output. Accepts partial inputs.
Example: 'input'
Data Types: char
Output Arguments
Pin direction, specified as a character vector. Returns 'unset'
if
the pin has not been configured since the last hardware start.
Example: 'unset'
Data Types: char
Version History
Introduced in R2015a
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)