Skip to main content

Rotary Knob Widget

⚡ Control

The Rotary Knob is a circular drag control that sends values to your device. It operates in two distinct modes: Knob (a bounded dial with a fixed range) and Encoder (an infinite-rotation input that sends a fixed value per tick, like a rotary encoder).

Default size: 2 × 2 grid cells

Preview

Rotary Knob Widget Preview

Widget appearance may vary slightly from the actual dashboard.


Modes

Knob mode

A classic bounded dial. The handle sweeps through a 270° arc from a minimum to a maximum value. Dragging the knob sends the proportional value to the device in real time or on release.

Use for: dimmer controls, volume, servo angle, setpoints, motor speed.

Encoder mode

An infinite-rotation dial with evenly spaced tick marks. Each full revolution consists of a configurable number of steps. Turning clockwise sends one fixed value; turning counter-clockwise sends another.

Use for: incremental control (menu navigation, step-by-step adjustment, stepper motors).


Configuration

Knob mode properties

PropertyTypeDefaultDescription
Modeknob | encoderknobSets the operating mode
Minnumber0Minimum value sent when handle is at start of arc
Maxnumber255Maximum value sent when handle is at end of arc
Stepnumber1Increment between discrete positions
Unitstring(none)Label displayed below the current value
Colorhex color#3B82F6Arc and handle accent color
Send on releasebooleantruetrue → send once on release; false → send continuously while dragging
DevicedeviceThe device to write to
PinV0V255The virtual pin to write to
LabelstringWidget label shown above the knob

Encoder mode properties

PropertyTypeDefaultDescription
ModeencoderSets the operating mode
Steps per revolutionnumber20Number of tick marks (and steps) per full rotation
CW valuestring1Value sent when rotated clockwise
CCW valuestring-1Value sent when rotated counter-clockwise
CW colorhex color#3B82F6Trail color for clockwise rotation
CCW colorhex color#f59e0bTrail color for counter-clockwise rotation
DevicedeviceThe device to write to
PinV0V255The virtual pin to write to
LabelstringWidget label shown above the knob

Firmware examples

Knob mode — LED brightness

// Receive brightness from Rotary Knob (0–255)
VWIRE_RECEIVE(V0) {
int brightness = param.asInt();
analogWrite(LED_PIN, brightness);
Vwire.virtualSend(V0, brightness); // echo back current value
}

Knob mode — servo angle

#include <Servo.h>
Servo myServo;

// Receive angle from Rotary Knob (0–180)
VWIRE_RECEIVE(V1) {
int angle = param.asInt();
myServo.write(angle);
}

void setup() {
myServo.attach(SERVO_PIN);
Vwire.config(AUTH_TOKEN);
Vwire.setDeviceId(DEVICE_ID);
Vwire.begin(WIFI_SSID, WIFI_PASSWORD);
}

Encoder mode — stepper motor direction

Configure the encoder widget with CW value = "1" and CCW value = "-1".

// Each tick sends "1" (CW) or "-1" (CCW)
VWIRE_RECEIVE(V2) {
int direction = param.asInt(); // 1 = CW, -1 = CCW
if (direction == 1) {
stepMotor(FORWARD, 1);
} else {
stepMotor(BACKWARD, 1);
}
}

Encoder mode — menu navigation

Configure with CW value = "next" and CCW value = "prev".

VWIRE_RECEIVE(V3) {
String cmd = param.asStr();
if (cmd == "next") {
menuNext();
} else if (cmd == "prev") {
menuPrev();
}
}

Restoring knob position on reconnect

In Knob mode, the knob position is automatically restored from the last stored pin value after reconnecting. Call Vwire.syncVirtual() in VWIRE_CONNECTED() to trigger the restore:

VWIRE_CONNECTED() {
Vwire.syncVirtual(V0); // restores knob to last saved position
}
note

Encoder mode is stateless by design — it does not restore position on reconnect, because the encoder value represents a direction command rather than an absolute position.


Knob vs Slider — when to use which

Rotary Knob (Knob)Slider
Interaction styleRotary dragLinear drag
Layout footprintSquare (2×2)Wide (3×1)
Best forCompact dashboards, physical dial feelLinear ranges, 1D control
Encoder/infinite✅ (encoder mode)