Documentation
Controls Configuration
Configure user input controls such as buttons, switches, and potentiometers.
Overview
Collecting user input is done through controls. Controls currently supported are button, switch, and potentiometer types. These controls can solve the majority of a system's user input needs.
To add a control to MudPi, place a control configuration object in the controls array within a control type worker. The minimum required options are type, pin, and key:
JSON
{
"workers": [{
"type": "control",
"controls": [
{
"type": "Button",
"pin": 2,
"key": "button_1"
}
]
}]
}
Settings
| Option | Type | Required | Description |
|---|---|---|---|
| `type` | String | Yes | Type of control. Options: `button`, `switch`, `potentiometer` |
| `pin` | Integer | Yes | GPIO pin number on Raspberry Pi the control is connected to. |
| `key` | String | Yes | Key to store value under in Redis. Alphanumeric with underscores only. |
| `name` | String | No | Friendly display name of the control. If not provided, the key is used with underscores replaced by spaces. |
Control Types
There are a number of controls supported by default with MudPi for both the Raspberry Pi and Arduino. The Pi is limited to digital GPIO only, which is why Arduinos are used for analog controls like potentiometers.
| Type | Returns | Description |
|---|---|---|
| Button | Boolean | Triggers on button press and release. Continues to fire events while pressed. |
| Switch | Boolean | Triggers on state change only once. |
| Potentiometer | Integer (0–1024) | Triggers on state change and sends current state in event. Has a value buffer of 3 before triggering. *Works on Arduino only.* |