GpioPin GpioPin GpioPin GpioPin Class

Definition

Represents a general-purpose I/O (GPIO) pin.

public : sealed class GpioPin : IGpioPin, IClosablepublic sealed class GpioPin : IGpioPin, IDisposablePublic NotInheritable Class GpioPin Implements IGpioPin, IDisposable// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)

Remarks

To get a GpioPin object, use the GpioController.OpenPin or GpioController.TryOpenPin method.

Properties

DebounceTimeout DebounceTimeout DebounceTimeout DebounceTimeout

Gets or sets the debounce timeout for the general-purpose I/O (GPIO) pin, which is an interval during which changes to the value of the pin are filtered out and do not generate ValueChanged events.

public : TimeSpan DebounceTimeout { get; set; }public TimeSpan DebounceTimeout { get; set; }Public ReadWrite Property DebounceTimeout As TimeSpan// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The debounce timeout for the GPIO pin, which is an interval during which changes to the value of the pin are filtered out and do not generate ValueChanged events. If the length of this interval is 0, all changes to the value of the pin generate ValueChanged events.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices
See Also

PinNumber PinNumber PinNumber PinNumber

Gets the pin number of the general-purpose I/O (GPIO) pin.

public : int PinNumber { get; }public int PinNumber { get; }Public ReadOnly Property PinNumber As int// You can use this property in JavaScript.
Value
int int int int

The pin number of the GPIO pin.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices

SharingMode SharingMode SharingMode SharingMode

Gets the sharing mode in which the general-purpose I/O (GPIO) pin is open.

public : GpioSharingMode SharingMode { get; }public GpioSharingMode SharingMode { get; }Public ReadOnly Property SharingMode As GpioSharingMode// You can use this property in JavaScript.
Value
GpioSharingMode GpioSharingMode GpioSharingMode GpioSharingMode

The sharing mode in which the GPIO pin is open.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices
See Also

Methods

Close() Close() Close() Close()

Closes the general-purpose I/O (GPIO) pin and releases the resources associated with it.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.

Remarks

You cannot call Close methods through Visual C++ component extensions (C++/CX) on Windows Runtime class instances where the class implemented IClosable. Instead, Visual C++ component extensions (C++/CX) code for runtime classes should call the destructor or set the last reference to null.

Dispose() Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()

GetDriveMode() GetDriveMode() GetDriveMode() GetDriveMode()

Gets the current drive mode for the general-purpose I/O (GPIO) pin. The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.

public : GpioPinDriveMode GetDriveMode()public GpioPinDriveMode GetDriveMode()Public Function GetDriveMode() As GpioPinDriveMode// You can use this method in JavaScript.
Returns

An enumeration value that indicates the current drive mode for the GPIO pin. The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices
See Also

IsDriveModeSupported(GpioPinDriveMode) IsDriveModeSupported(GpioPinDriveMode) IsDriveModeSupported(GpioPinDriveMode) IsDriveModeSupported(GpioPinDriveMode)

Gets whether the general-purpose I/O (GPIO) pin supports the specified drive mode.

public : PlatForm::Boolean IsDriveModeSupported(GpioPinDriveMode driveMode)public bool IsDriveModeSupported(GpioPinDriveMode driveMode)Public Function IsDriveModeSupported(driveMode As GpioPinDriveMode) As bool// You can use this method in JavaScript.
Parameters
driveMode
GpioPinDriveMode GpioPinDriveMode GpioPinDriveMode GpioPinDriveMode

The drive mode that you want to check for support.

Returns
PlatForm::Boolean bool bool bool

True if the GPIO pin supports the drive mode that driveMode specifies; otherwise false. If you specify a drive mode for which this method returns false when you call SetDriveMode, SetDriveMode generates an exception.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices
See Also

Read() Read() Read() Read()

Reads the current value of the general-purpose I/O (GPIO) pin.

public : GpioPinValue Read()public GpioPinValue Read()Public Function Read() As GpioPinValue// You can use this method in JavaScript.
Returns

The current value of the GPIO pin. If the pin is configured as an output, this value is the last value written to the pin.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices
See Also

SetDriveMode(GpioPinDriveMode) SetDriveMode(GpioPinDriveMode) SetDriveMode(GpioPinDriveMode) SetDriveMode(GpioPinDriveMode)

Sets the drive mode of the general-purpose I/O (GPIO) pin. The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.

public : void SetDriveMode(GpioPinDriveMode value)public void SetDriveMode(GpioPinDriveMode value)Public Function SetDriveMode(value As GpioPinDriveMode) As void// You can use this method in JavaScript.
Parameters
value
GpioPinDriveMode GpioPinDriveMode GpioPinDriveMode GpioPinDriveMode

An enumeration value that specifies drive mode to use for the GPIO pin. The drive mode specifies whether the pin is configured as an input or an output, and determines how values are driven onto the pin.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices

Remarks

The following exceptions can be thrown by this method:

E_INVALIDARG

The GPIO pin does not support the specified drive mode.

E_ACCESSDENIED

The pin is open in shared read-only mode. Close the pin and reopen it in exclusive mode to change the drive mode of the pin.

See Also

Write(GpioPinValue) Write(GpioPinValue) Write(GpioPinValue) Write(GpioPinValue)

Drives the specified value onto the general purpose I/O (GPIO) pin according to the current drive mode for the pin if the pin is configured as an output, or updates the latched output value for the pin if the pin is configured as an input.

public : void Write(GpioPinValue value)public void Write(GpioPinValue value)Public Function Write(value As GpioPinValue) As void// You can use this method in JavaScript.
Parameters
value
GpioPinValue GpioPinValue GpioPinValue GpioPinValue

The enumeration value to write to the GPIO pin.

If the GPIO pin is configured as an output, the method drives the specified value onto the pin according to the current drive mode for the pin.

If the GPIO pin is configured as an input, the method updates the latched output value for the pin. The latched output value is driven onto the pin when the configuration for the pin changes to output.

Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices

Remarks

The following exceptions can be thrown by this method:

E_ACCESSDENIED

The GPIO pin is open in shared read-only mode. To write to the pin, close the pin and reopen the pin in exclusive mode.

See Also

Events

ValueChanged ValueChanged ValueChanged ValueChanged

Occurs when the value of the general-purpose I/O (GPIO) pin changes, either because of an external stimulus when the pin is configured as an input, or when a value is written to the pin when the pin in configured as an output.

public : event TypedEventHandler ValueChanged<GpioPin,  GpioPinValueChangedEventArgs>public event TypedEventHandler ValueChanged<GpioPin,  GpioPinValueChangedEventArgs>Public Event ValueChanged<GpioPin,  GpioPinValueChangedEventArgs>// You can use this event in JavaScript.
Additional features and requirements
Device family
Windows IoT Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v1)
Capabilities
lowLevelDevices