Potentiometers

Available methods

Configuration

  • setAnalogMax(analogMax) - Set the maximum value returned by analogRead(). Defaults to 1023 (10-bit ADC). Set to 4095 for boards with 12-bit ADCs (ESP32, Teensy, RP2040, STM32, etc.).
  • setMultiplexer(&mux) - Sets the multiplexer that the potentiometer subscribes to.
  • setGroup(&group) - Register the potentiometer to a group.

Core

  • process() - Polls the potentiometer and handles all its functionality (used in the loop method).
  • setRawValue(rawValue) - Provide an externally-read raw ADC value. Use this instead of process() when reading the ADC externally (e.g., via DMA or async ADC). Smoothing and value change detection are still applied.
  • storeRaw(rawValue) - Store a raw ADC value from an ISR or DMA callback. Call this from your timer ISR or DMA completion handler. It stores the value in an internal volatile buffer without any processing. The next call to process() will consume the stored value and apply smoothing, mapping, and change detection as normal.

Event handlers

  • setOnValueChange(handler) - Sets the onValueChange handler. Called as soon as the reading of the potentiometer changes.

State

  • getValue() - Retrieves the current value of the potentiometer.
  • getAnalogMax() - Get the maximum value returned by analogRead().
  • isEnabled() - Checks if the potentiometer is enabled.
  • isDisabled() - Checks if the potentiometer is disabled.
  • isMuxed() - Checks if the potentiometer is currently attached to a multiplexer.
  • isGrouped() - Checks if the potentiometer is currently added to a group.
  • enable() - Enables the potentiometer.
  • disable() - Disables the potentiometer.

Custom properties

  • setInteger("id", 0) - Define an integer. First parameter is the name, second is the value.
  • setString("name", "Potentiometer") - Define a string. First parameter is the name, second is the value.
  • setBoolean("active", true) - Define a boolean. First parameter is the name, second is the value.
  • getInteger("id") - Get the value of an integer.
  • getString("name") - Get the value of a string.
  • getBoolean("active") - Get the value of a boolean.
Previous
Dual action button