[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
Code examples
Arduino projects: 15_potentiometer
#include <TotemModule15.h>
TotemModule15 module;
Function usage (click to expand)
/* Knob control */
// Read knob A value "128"
int knobA = module.getKnobA();
// Change knob resolution to 12 bits
module.setKnobBits(12);
// Read knob B value "2048"
int knobB = module.getKnobB();
// Read knob C value "0"
int knobC = module.getKnobC();
/* Button */
// Check if button A is pressed
bool isInA = module.getButtonA();
// Check if button B is pressed or released
bool isInB = module.getButtonB();
// Check if button C is pressed or released
bool isInC = module.getButtonC();
/* 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[0].on();
// Set LED B off
module.led[1].off();
// Set LED C to off
module.led[2].set(LOW);
// Toggle LED A state on / off
module.led[0].toggle();
// Check if LED B is on "false"
bool isOn = module.led[1].isOn();
// Set LED C brightness to 100%
module.led[2].setAlpha(255);
Functions
Knob control
position
module.getKnobA()
¶
position
module.getKnobB()
¶
position
module.getKnobC() ¶-
Get knob position. (0, 128, 255) = (left, center, right).
Returned value range depends onsetKnobBits()
(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.getButtonA()
¶
state
module.getButtonB()
¶
state
module.getButtonC() ¶-
Check if button is pressed.
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 its number. 0 - A, 1 - B, 2 - C.
Individual LED can be accessed by specifying index: module.rgb[0].on()
.
LED from A to C is identified as indexes 0
-2
.
Accessing "without index" will affect all LED.
Low level commands
These are low level TotemBUS commands accepted by module. Is not required when using objective API described above.
Command list
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 |