# set – skriv kanalvärde

> Skriver ett värde till en kanal — för att styra digital I/O, sätta DAC-värden och konfigurera lägen.

_Källa: E-Sharp (esharp.se) · Accordion Shell (CLI)_


## Description

The `set` command writes a value to a specified channel. It's used to configure hardware settings, control digital I/O, and modify channel states.

## Syntax

```bash
set --channel <channel_name> --value <value>
```

## Required Options

| Option | Short | Description |
| --- | --- | --- |
| `--channel` | `-c` | The name or alias of the channel to set |
| `--value` | `-v` | The value to write to the channel |

## Examples

```bash
set --channel "GPIO_PIN_5" --value "1"
set --channel "DAC_OUTPUT" --value "2.5"
set --channel "DEVICE_NAME" --value "TestDevice"
set --channel "MODE_SELECT" --value "AUTO"
set -c "ENABLE" -v "true"
```

## Value Types

| Channel Type | Example Values |
| --- | --- |
| Boolean | `"true"`, `"false"`, `"1"`, `"0"` |
| Integer | `"0"`, `"100"`, `"-5"` |
| Float/Double | `"3.14"`, `"2.5"`, `"-1.23"` |
| String | `"any text"`, `"DeviceName"` |
| Enumeration | `"OPTION1"`, `"MODE_A"` |
| Hexadecimal | `"0xFF"`, `"0x1A2B"` |

## Behavior

1. Resolves the channel name
2. Converts the value to the appropriate type
3. Sends the value to the hardware
4. Value is applied immediately

## Notes

- Requires an active connection (use `init` first)
- Values are applied immediately
- Some channels may have restricted value ranges
- Hardware validation may reject invalid values

## Error Handling

- **Channel not found**: Verify channel name with `list`
- **Invalid value**: Check channel data type and valid range
- **Read-only channel**: Some channels cannot be written
- **Value out of range**: Hardware rejected the value
- **Not connected**: Run `init` command first
