Docs

Volume

The Volume widget sends a level from 0 to 100, drawn like a media control.

Use it for: an amplifier, a buzzer, a speaker board, anything where the user already thinks in terms of volume.

SettingWhat it does
Pinthe virtual pin your code reads
Min, Maxthe range, 0 to 100 by default
Send on releasesend once when you lift your finger

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Example

A volume level driving a digital potentiometer over I2C.

volume.ino
#include <Wire.h>
#include <PlynxSimpleEsp32.h>

#define POT_ADDRESS 0x2C

PLYNX_WRITE(V35)
{
  int level = param.asInt();          // 0 to 100
  int step = map(level, 0, 100, 0, 127);

  Wire.beginTransmission(POT_ADDRESS);
  Wire.write(0x00);
  Wire.write(step);
  Wire.endTransmission();
}

void setup()
{
  Serial.begin(115200);
  Wire.begin();

  // Auto setup: WiFi and the Plynx token are configured from the app.
  //
  // To provide them directly in the sketch instead, use:
  //   Plynx.begin(auth, ssid, pass);
  Plynx.begin();
}

void loop()
{
  Plynx.run();
}

map() converts the widget range to whatever your hardware wants. A digital pot with 128 steps needs 0 to 127, not 0 to 100.

Volume sounds linear and is not. Halving the number does not halve what you hear, so a logarithmic curve in code feels closer to right.

Troubleshooting

ProblemCheck
No sound at low settingsthe hardware has a floor; map to a narrower range
Most of the travel does nothingthe response is logarithmic; convert in code
Value stops at 100the widget Max, not the sketch
I2C writes failthe device address, and pull-ups on SDA and SCL

Next