readDigitalPin
Description
value = readDigitalPin(
reads the logic level value of the digital input pin controller,pin)pin on the
Aardvark™ or NI™ USB-845x controller controller and returns it as a double
0 or 1.
Examples
Connect to an NI USB-845x Interface Device and read the logic level values of its digital I/O pins.
Connect to the NI USB-845x using its serial number. In this example, the NI USB-845x controller board that is connected to the computer has the serial
number 01F26E0A.
controller = ni845x("01F26E0A");View the available digital I/O (DIO) pins on the controller and their respective pin
modes by using the DigitalPinModes property.
controller.DigitalPinModes
ans =
8×2 table
Pin Mode
______ _______
"P0.0" "input"
"P0.1" "input"
"P0.2" "input"
"P0.3" "input"
"P0.4" "input"
"P0.5" "input"
"P0.6" "input"
"P0.7" "input"
Since these are input pins, you can read the logic level value of any of these. These pins are connected to pins on the I2C peripheral device. Read the logic level value of the DIO(0) pin, P0.0.
value = readDigitalPin(controller,"P0.0")value =
0
You can also read the values of all the pins at once.
value = readDigitalPin(controller,controller.AvailableDigitalPins)
value =
0 1 1 0 0 1 1 0
The order of these values corresponds to the order of the pins returned by
controller.DigitalPinModes. For example, the value of
P0.0 is 0, P0.1 is
1, P0.2 is 1, and so
on.
Input Arguments
Controller connection, specified as an aardvark object or
ni845x object.
Example: readDigitalPin(controller,pin) reads the pin's logic
level value for the Aardvark or NI USB-845x controller controller.
Digital input pin number to read the logic level value of, specified as a character
vector or string. Possible values are the pin numbers returned as strings by
controller.AvailableDigitalPins. You can also read the values of
all the pins by specifying pin as the string array returned by
controller.AvailableDigitalPins.
If a digital pin is not already configured as an input pin, you can set it using the
configureDigitalPin
function.
Example: readDigitalPin(controller,"Pin1") reads the logic level
of the pin "Pin1" on the Aardvark controller.
Example: readDigitalPin(controller,"P0.0") reads the logic level
of the pin "P0.0" on the NI USB-845x controller.
Data Types: char | string
Version History
Introduced in R2023a
See Also
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)