What is it?

A single IR range sensor module (H08R60) and size RGB LED modules (H01R00) are used in the project. A push button is connected to one of the LED modules to cycle through different modes.


  • 1 x H08R60 Hexabitz Time-of-flight IR Sensor Module
  • 6 x H01R00 Hexabitz RGB LED Module
  • 1 x TL59FF160Q Momentary tactile push button

Estimated hardware build time: 10 minutes 

Estimated software development time: 1 hour

Have suggestions about how to improve our demo projects? Feel free to comment below or send us a private message!


The IR sensor module does all the work basically. It detects motion (or measures distance) and generates a control command that is broadcasted to all LED modules. Since the sensor is in the middle of the array, the button is read by one of the LED modules and its value is sent to the sensor module by a memory write API.

We didn't define a fixed topology in this project. Instead, we ran the exploration command starting from the module connected to the button and let the modules generate their own topology as shown below.

Attached project firmware includes two uVision projects. Once for the IR sensor module (H08R6) and another for the LED modules (H01R0). Note that for LEDs, all of them except the one with the button are using exact firmware. That's why we created only two targets in that project: Target 1 for module 1 connected to the push button and Target 2 for all other LED modules.

Mode 1

First LED click turns off all LEDs. When the array powers on mode counter starts from zero but you can start from 1 as well. Each button click also triggers an indicator LED blink.

Mode 2

This mode cycles through colors by changing distance.

Mode 3

This mode varies through LED intensity based on distance. Note how it saves you last setting so that intensity doesn't jump to maximum when you remove your hand.

Mode 4

This mode swipes right or left to turn the LEDs ON/OFF.

Mode 5

This mode swipes right or left to cycle through LED colors. So fun!

Code Description

As mentioned before, the RGB LED code is very simple. Basically all LED modules have native module firmware except the one connected to the push button which has a simple code that defines a button with a click callback. In the callback, the code cycles through modes and writes the value to a BOS variable via a remote write API. Check this article about remote memory access in Hexabitz arrays.

The sensor module code is a bit more complicated but easy to understand. First we define a BOS variable that the remote RGB LED module will write to. Then, we set sensor units to mm and stream range continuously to a memory variable at 20 Hz.

After that, we cycle through modes at 100 Hz and broadcast the appropriate message for each mode. For example, mode 1 just broadcasts a turn OFF message to all LEDs. Check this article for more details about messaging in Hexabitz.

In modes 2 and 3, we convert measured absolute range directly into color or use it to cycle through available basic colors and then broadcast a set color message. Color mapping for absolute distance is straightforward. The HorizontalSweepToColor() function calls another function that detects a sweep or a motion. The HorizontalSweepToColor() then cycles through detected sweeps to change color. 

Note how the broadcast message is only sent if there's a color change and not at the loop 100 Hz rate:

Mode 5 has a lock state. If the measured range is > h08r6MaxRange, this means there's no object in the sensor field of view and the intensity shouldn't get updated. If distance to an object is > 100 mm, that distance is converted into a valid intensity value.