Configure a GPIO/ADC based input controller
Configuring a gpio
input controller allows you to use a GPIO or ADC based device to communicate with your robot.
Configuration
Refer to the following example configuration for an input controller of model gpio
with a GPIO based device serving as the board component.
Be aware that complete configuration is not visible in the “Config Builder” tab:
Navigate to the Config tab of your robot’s page in the Viam app.
Click on the Components subtab and click Create component.
Select the input_controller
type, then select the gpio
model.
Enter a name for your input controller and click Create.
Edit and fill in the attributes as applicable.
{
"components": [
{
"name": "<your-gpio-input-controller-name>",
"type": "input_controller",
"model": "gpio",
"attributes": {
"board": "<your-board-name>",
"buttons": {
"<your-button-name>": {
"control": "<button-control-name>",
"invert": <boolean>,
"debounce_msec": <#>
}
},
"axes": {
"<nyour-axis-name>": {
"control": "<axis-control-name>",
"min": <#>,
"max": <#>,
"poll_hz": <#>,
"deadzone": <#>,
"min_change": <#>,
"bidirectional": <boolean>,
"invert": <boolean>
}
}
},
"depends_on": [
"<your-board-name>"
]
}, ... // <INSERT ANY ADDITIONAL COMPONENT CONFIGURATION>
}
{
"components": [
{
"name": "my_gpio_ic",
"type": "input_controller",
"model": "gpio",
"attributes": {
"board": "piboard",
"buttons": {
"interrupt1": {
"control": "ButtonNorth",
"invert": false,
"debounce_msec": 5
},
"interrupt2": {
"control": "ButtonSouth",
"invert": true,
"debounce_msec": 5
}
},
"axes": {
"analogReader1": {
"control": "AbsoluteX",
"min": 0,
"max": 1023,
"poll_hz": 50,
"deadzone": 30,
"min_change": 5,
"bidirectional": false,
"invert": false
},
"analogReader2": {
"control": "AbsoluteY",
"min": 0,
"max": 1023,
"poll_hz": 50,
"deadzone": 30,
"min_change": 5,
"bidirectional": true,
"invert": true
}
}
},
"depends_on": [
"piboard"
]
}, ...
}
The following attributes are available for gpio
input controllers:
Name | Type | Inclusion | Description |
---|---|---|---|
board | string | Required | The name of the board component with GPIO or ADC pins to use as the controlling device. |
buttons | object | Required | The Buttons available for control. These should be connected to the GPIO/ADC board. Each button has the following fields:
|
axes | object | Required | The Axes available for control. These should be connected to the GPIO/ADC board. Each axis has the following fields:
|
Troubleshooting
You can find additional assistance in the Troubleshooting section.
You can also ask questions in the Community Discord and we will be happy to help.
Have questions, or want to meet other people working on robots? Join our Community Discord.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!