Table of Contents

Class GpioPin

Namespace
System.Device.Gpio
Assembly
System.Device.Gpio.dll

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

public sealed class GpioPin : IDisposable
Inheritance
GpioPin
Implements
Inherited Members
Extension Methods

Properties

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; }

Property Value

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.

PinNumber

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

public int PinNumber { get; }

Property Value

int

The pin number of the GPIO pin.

Methods

Dispose()

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

public void Dispose()

Finalize()

protected override void Finalize()

GetPinMode()

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

public PinMode GetPinMode()

Returns

PinMode

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

IsPinModeSupported(PinMode)

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

public bool IsPinModeSupported(PinMode pinMode)

Parameters

pinMode PinMode

The pin mode that you want to check for support.

Returns

bool

true if the GPIO pin supports the pin mode that pinMode specifies; otherwise false. If you specify a pin mode for which this method returns false when you call SetPinMode(PinMode), SetPinMode(PinMode) generates an exception.

Read()

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

public PinValue Read()

Returns

PinValue

The current value of the GPIO pin. If the pin is configured as an output, the read value is undetermined.

SetPinMode(PinMode)

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

public void SetPinMode(PinMode value)

Parameters

value PinMode

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

Exceptions

ArgumentException

The GPIO pin does not support the specified pin mode.

Toggle()

Toggles the output of the general purpose I/O (GPIO) pin if the pin is configured as an output.

public void Toggle()

Write(PinValue)

Drives the specified value onto the general purpose I/O (GPIO) pin according to the current pin 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(PinValue value)

Parameters

value PinValue

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 pin 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.

Exceptions

InvalidOperationException

This exception will be thrown on an attempt to write to a pin that hasn't been opened or is not configured as output.

Events

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 PinValueChangedEventHandler ValueChanged

Event Type

PinValueChangedEventHandler