Previous
Board
The button API allows you to get button presses from your button components.
The button component supports the following methods:
Method Name | Description | viam-micro-server Support |
---|---|---|
Push | Push the button. | |
DoCommand | Execute model-specific commands that are not otherwise defined by the component API. | |
Close | Safely shut down the resource and prevent further use. |
To get started using Viam’s SDKs to connect to and control your button and the rest of your machine, go to your machine’s page on the Viam app, Navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.
To show your machine’s API key in the sample code, toggle Include API key.
We strongly recommend that you add your API key and machine address as an environment variable. Anyone with these secrets can access your machine, and the computer running your machine.
When executed, this sample code creates a connection to your machine as a client.
The following examples assume you have an button called "my_button"
configured as a component of your machine.
If your button has a different name, change the name
in the code.
Import the button package for the SDK you are using:
Push the button.
Execute model-specific commands that are not otherwise defined by the component API.
For built-in models, model-specific commands are covered with each model’s documentation.
If you are implementing your own button and add features that have no built-in API method, you can access them with DoCommand
.
Safely shut down the resource and prevent further use.
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!