Skip to content

[15] Potentiometer module

Description

Module designed to provide input for robotic application. 3 analog knobs and 3 buttons allow to execute specific actions or adjust parameters. Can be used for motor speed, PID adjusting, servo position, RGB color and anything other.

Features:

  • 3 analog knobs
  • 3 buttons
  • 3 individual brightness leds

Totem Module 15

Code examples

Arduino projects: 15_potentiometer

Module15 module;
Function usage (click to expand)
/* Knob control */
// Read knob A value "128"
int knobA = module.knobA.get();
// Change knob resolution to 12 bits
module.setKnobBits(12);
// Read knob B value "2048"
int knobB = module.knobB.get();
// Read knob C value "0"
int knobC = module.knobC.get();
/* Button */
// Check if button A is pressed or released
bool isInA = module.buttonA.isPressed();
bool isOutA = module.buttonA.isReleased();
// Check if button B is pressed or released
bool isInB = module.buttonB.isPressed();
bool isOutB = module.buttonB.isReleased();
// Check if button C is pressed or released
bool isInC = module.buttonC.isPressed();
bool isOutC = module.buttonC.isReleased();
/* All LED control */
// Turn all LED on
module.led.on();
// Turn all LED off
module.led.off();
// Set all LED to on
module.led.set(HIGH);
// Toggle all LED state on / off
module.led.toggle();
// Check if any LED is on
bool isOn = module.led.isOn();
// Set all LED brightness to 50%
module.led.setAlpha(128);
// Set all LED state to: A:on, B:off, C:on
module.led.setBinary(B101);
// Reset all LED to default behavior
module.led.reset();
/* Single LED control */
// Set LED A on
module.led.onX(0);
// Set LED B off
module.led.offX(1);
// Set LED C to off
module.led.setX(2, LOW);
// Toggle LED A state on / off
module.led.toggleX(0);
// Check if LED B is on "false"
bool isOn = module.led.isOnX(1);
// Set LED C brightness to 100%
module.led.setAlphaX(2, 255);

Functions

Knob control

(position) module.knobA.get()

(position) module.knobB.get()

(position) module.knobC.get()

Get knob position. (0, 128, 255) = (left, center, right).
Returned value range depends on setKnobBits() (resolution) setting.
Returns:
position - knob position [0:255]

module.setKnobBits(resolution)

Set knob resolution. knobX.get() will return value according to this parameter.
Allowed values:
6 - [0:64]
8 - [0:256] (default)
10 - [0:1024]
12 - [0:4096]
Parameter:
resolution - knob analog resolution in bits. [6,8,10,12], Default: 8

Button

(state) module.buttonA.isPressed()

(state) module.buttonB.isPressed()

(state) module.buttonC.isPressed()

Check if button is pressed.
Returns:
status - yes / no [true:false]

(state) module.buttonA.isReleased()

(state) module.buttonB.isReleased()

(state) module.buttonC.isReleased()

Check if button is released.
Returns:
status - yes / no [true:false]

All LED control

module.led.on()

Turn all LED on.

module.led.off()

Turn all LED off.

module.led.set(state)

Set all LED to specific state (on / off).
Parameter:
state - state on / off [HIGH:LOW] or [true:false]

module.led.toggle()

Toggle all LED between on / off states.

(state) module.led.isOn()

Check if any of LED is on.
Returns:
state - is any LED on [true:false] or [HIGH:LOW].

module.led.setAlpha(alpha)

Set all LED brightness.
Parameter:
alpha - brightness [0:255].

module.led.setBinary(mask)

Set all LED state with single value mask.
Each bit represents individual LED state. B100 - A, B010 - B, B001 - C.
Parameter:
state - binary mask [B000:B111].

module.led.reset()

Re-enable default behavior of LED. It is switched off when any of LED function is used.

Single LED control

Control specific LED by providing it's number. 0 - A, 1 - B, 2 - C.

module.led.onX(number)

Turn single LED on.
Parameter:
number - LED array number [0:2]

module.led.offX(number)

Turn single LED off.
Parameter:
number - LED array number [0:2]

module.led.setX(number, state)

Set all LED to specific state (on / off).
Parameter:
number - LED array number [0:2]
state - state on / off [HIGH:LOW] or [true:false]

module.led.toggleX(number)

Toggle single LED between on / off states.
Parameter:
number - LED array number [0:2]

(state) module.led.isOnX(number)

Check if specific LED is on.
Parameter:
number - LED array number [0:2]
Returns:
state - is LED on [true:false] or [HIGH:LOW].

module.led.setAlphaX(number, alpha)

Set single LED brightness.
Parameter:
number - LED array number [0:2]
alpha - brightness [0:255].

Low level commands

These are low level TotemBUS commands accepted by module. Is not required when using objective API described above.

Command Parameters Description
knobA Returns:(int) Knob A position
knobB Returns:(int) Knob B position
knobC Returns:(int) Knob C position
knobAll/bits (int) Set knob resolution in bits
ledAll/reset None Reset LED to default behavior
ledAll (int) Set all LED brightness (%)
ledA (int) Set LED A brightness (%)
ledB (int) Set LED B brightness (%)
ledC (int) Set LED C brightness (%)
buttonA Returns:(bool) Is button A pressed
buttonB Returns:(bool) Is button B pressed
buttonC Returns:(bool) Is button C pressed