# Board API

The board API allows you to give commands to your [board components](https://docs.viam.com/reference/components/board/) for setting GPIO pins to high or low, setting PWM, and working with analog and digital interrupts.

The board component supports the following methods:

| Method Name | Description | `viam-micro-server` Support |
| --- | --- | --- |
| [`SetGPIO`](https://docs.viam.com/reference/apis/components/board/#setgpio) | Set the digital signal output of this pin to low (0V) or high (active, >0V). |  |
| [`GetGPIO`](https://docs.viam.com/reference/apis/components/board/#getgpio) | Get if the digital signal output of this pin is high (active, >0V). |  |
| [`GetPWM`](https://docs.viam.com/reference/apis/components/board/#getpwm) | Get the pin’s pulse-width modulation (PWM) duty cycle: a float \[`0.0`, `1.0`\] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency). |  |
| [`SetPWM`](https://docs.viam.com/reference/apis/components/board/#setpwm) | Set the pin’s Pulse-width modulation (PWM) duty cycle: a float \[`0.0`, `1.0`\] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency). |  |
| [`PWMFrequency`](https://docs.viam.com/reference/apis/components/board/#pwmfrequency) | Get the PWM frequency of the GPIO pin. |  |
| [`SetPWMFrequency`](https://docs.viam.com/reference/apis/components/board/#setpwmfrequency) | Set the pin to the given PWM `frequency` (in Hz). When `frequency` is 0, it will use the board’s default PWM frequency. |  |
| [`GetDigitalInterruptValue`](https://docs.viam.com/reference/apis/components/board/#getdigitalinterruptvalue) | Get the current value of a configured digital interrupt. |  |
| [`ReadAnalogReader`](https://docs.viam.com/reference/apis/components/board/#readanalogreader) | Read the current integer value of the digital signal output by the ADC. |  |
| [`WriteAnalog`](https://docs.viam.com/reference/apis/components/board/#writeanalog) | Write an analog value to a pin on the board. |  |
| [`StreamTicks`](https://docs.viam.com/reference/apis/components/board/#streamticks) | Start a stream of `DigitalInterrupt` ticks. |  |
| [`SetPowerMode`](https://docs.viam.com/reference/apis/components/board/#setpowermode) | Set the board to the indicated `PowerMode`. |  |
| [`AnalogByName`](https://docs.viam.com/reference/apis/components/board/#analogbyname) | Get a configured `Analog` by `name`. |  |
| [`DigitalInterruptByName`](https://docs.viam.com/reference/apis/components/board/#digitalinterruptbyname) | Get a DigitalInterrupt by `name`. |  |
| [`GPIOPinByName`](https://docs.viam.com/reference/apis/components/board/#gpiopinbyname) | Get a `GPIOPin` by pin number. |  |
| [`GetGeometries`](https://docs.viam.com/reference/apis/components/board/#getgeometries) | Get all the geometries associated with the board in its current configuration, in the frame of the board. |  |
| [`Reconfigure`](https://docs.viam.com/reference/apis/components/board/#reconfigure) | Reconfigure this resource. |  |
| [`DoCommand`](https://docs.viam.com/reference/apis/components/board/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. |  |
| [`GetResourceName`](https://docs.viam.com/reference/apis/components/board/#getresourcename) | Get the `ResourceName` for this board. |  |
| [`Close`](https://docs.viam.com/reference/apis/components/board/#close) | Safely shut down the resource and prevent further use. |  |

## API

### SetGPIO

Set the digital signal output of this pin to low (0V) or high (active, >0V).
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/board/#tabset-referenceapiscomponentsboard-1-0)
- [Go](https://docs.viam.com/reference/apis/components/board/#tabset-referenceapiscomponentsboard-1-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/board/#tabset-referenceapiscomponentsboard-1-2)
- [Flutter](https://docs.viam.com/reference/apis/components/board/#tabset-referenceapiscomponentsboard-1-3)

**Parameters:**

- `high` ( [bool](https://docs.python.org/3/library/stdtypes.html#boolean-type-bool)) (required): When true, sets the pin to high. When false, sets the pin to low.
- `extra` (Mapping\[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any\]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- None.

**Example:**

```python

```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/board/client/index.html#viam.components.board.client.GPIOPinClient.set).

### GetGPIO

Get if the digital signal output of this pin is high (active, >0V).
Supported by `viam-micro-server`.

**Parameters:**

- `extra` (Mapping\[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any\]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- ( [bool](https://docs.python.org/3/library/stdtypes.html#boolean-type-bool)): : Indicates if the state of the pin is high.

### GetPWM

Get the pin’s [pulse-width modulation (PWM) duty cycle](https://learn.sparkfun.com/tutorials/pulse-width-modulation/duty-cycle): a float \[`0.0`, `1.0`\] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal [(interval period being the mathematical inverse of the PWM frequency)](https://learn.adafruit.com/improve-brushed-dc-motor-performance/pwm-frequency).
Supported by `viam-micro-server`.

**Parameters:**

**Returns:**

- ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): : The duty cycle.

### SetPWM

Set the pin’s [Pulse-width modulation (PWM) duty cycle](https://learn.sparkfun.com/tutorials/pulse-width-modulation/duty-cycle): a float \[`0.0`, `1.0`\] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal [(interval period being the mathematical inverse of the PWM frequency)](https://learn.adafruit.com/improve-brushed-dc-motor-performance/pwm-frequency).
Supported by `viam-micro-server`.

**Parameters:**

- `duty_cycle` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): The duty cycle.
- `extra` (Mapping\[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any\]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- None.

### PWMFrequency

Get the PWM frequency of the GPIO pin.
Supported by `viam-micro-server`.

**Parameters:**

**Returns:**

- ( [int](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): : The PWM frequency.

### SetPWMFrequency

Set the pin to the given PWM `frequency` (in Hz). When `frequency` is 0, it will use the board’s default PWM frequency.

### GetDigitalInterruptValue

Get the current value of a configured digital interrupt. The value is the number of times the interrupt has been interrupted with a tick.

### ReadAnalogReader

Read the current integer value of the digital signal output by the ADC.

### WriteAnalog

Write an analog value to a pin on the board.

### StreamTicks

Start a stream of `DigitalInterrupt` ticks.

### SetPowerMode

Set the board to the indicated `PowerMode`.

### AnalogByName

Get a configured `Analog` by `name`.

### DigitalInterruptByName

Get a DigitalInterrupt by `name`.

### GPIOPinByName

Get a `GPIOPin` by pin number.

### GetGeometries

Get all the geometries associated with the board in its current configuration, in the [frame](https://docs.viam.com/reference/services/frame-system/) of the board.

### Reconfigure

Reconfigure this resource.

### DoCommand

Execute model-specific commands that are not otherwise defined by the component API.

### GetResourceName

Get the `ResourceName` for this board.

### Close

Safely shut down the resource and prevent further use.
