Skip to content

[11] Distance module


Module designed for measuring distance to an obstacle. It uses infrared laser sensor to avoid limitations of ultrasonic counterparts.
With included 8 color LED, module can be used for car headlights or distance indication.


  • Laser distance sensing (range 3-130 cm)
  • 8 individual controllable RGB lights

Totem Module 11

Code examples

Arduino projects: 11_distance

TotemModule11 module;
Function usage (click to expand)

/* Distance */
// Read distance in millimeters
float distMM = module.getMM();
// Read distance in centimeters
float distCm = module.getCm();
// Read distance in foot
float distFoot = module.getFoot();
// Read distance in inches
float distInch = module.getInch();
// Check if some objet is detected
bool inRange = module.isDetected();
/* All RGB lights control */
// Set all LED to "Totem" colors
// Set all LED to green color
module.rgb.color(0, 255, 0);
// Turn all LED on
// Turn all LED off;
// Set all LED to on
// Toggle all LED state on / off
// Check if any LED is on
bool isOn = module.rgb.isOn();
// Enable bright mode
/* Single RGB light control */
// Set LED 1 to color red
module.rgb[0].color(255, 0, 0);
// Set LED 4 to color green
module.rgb[3].color(0, 255, 0);
// Set LED 8 to color blue
module.rgb[7].color(0, 0, 255);



(distance) module.getMM()

Get distance between module and barrier in millimeters.
distance - millimeters to object ~[30:1300]mm. 0 - not detected.

(distance) module.getCm()

Get distance between module and barrier in centimeters.
distance - centimeters to object ~[3:130]cm. 0 - not detected.

(distance) module.getFoot()

Get distance between module and barrier in foot.
distance - foot to object (float) ~[0.098:4.265]ft. 0 - not detected.

(distance) module.getInch()

Get distance between module and barrier in inches.
distance - inches to object (float) ~[1.181:51.181]inch. 0 - not detected.

(isDetected) module.isDetected()

Check if object is in sensing range (detected).
isDetected - object detected [true:false].

All RGB lights control


Set all LED to "Totem" colors (blue, yellow, green).

module.rgb.color(red, green, blue)


Set LED color with automatic RGB or HEX parameter. More convenient to use compared to ones with explicit format.
Alpha value in hex is ignored.
red - amount of red color [0:255]
green - amount of green color [0:255]
blue - amount of blue color [0:255]
hex - hexadecimal color code [0x000000:0xFFFFFF]


Turn all LED on to last used color.

Turn all LED off.


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


Toggle all LED between on / off states.

(state) module.rgb.isOn()

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


Disable multiplexing if all LED is set to the same color. This results in much more brightness.
This mode is required to be enabled each time module is powered up. This is disabled by default to match brightness when using color, colorX commands.
state - bright mode is on [true:false]. Default: false

Single RGB light control

Individual LED can be accessed by specifying index: module.rgb[0].on().
LED from 1 to 8 is identified as indexes 0-7.
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 Parameters Description
distance Returns:(int) Get distance to object in mm
rgbAll/totem None Set LED to Totem colors
rgbAll/bright (bool) Enable bright LED mode
rgbAll (byte, byte, byte) Set all LED color
rgbX (byte, byte, byte, byte) Set specific LED color