RoboHeart Part 2

The part of the robot heart sculpture hack that worked as planned was the illumination of the heart. I used a ThingM BlinkM MaxM, which is a monster programmable RGB LED.

BlinkM MaxM

The MaxM has two parts – the LEDs themselves and a controller board. The controller board contains a small AVR microcontroller and can be programmed with sequences, or it can be controlled by an Arduino (or any device that can supply 5 volts and a an I2C serial signal.

ThingM makes a programmer interface called a LinkM for programming the BlinkM using a computer’s USB port.


They provide free tools to set up sequences. You can have 8 sequences of 48 steps each. Each RGB component is 8 bits, for a total of 24 each sequence step. This totals 9 KiB for everything, a limit of the AVR microcontroller used on the RGB controller board.

I wanted to program a heart beat sequence in the first slot because this becomes default behavior when the BlinkM is powered on.

Here’s where we hit our first challenge.

If the 48 available steps needs to go from black (RGB 0,0,0) to red (RGB 255,0,0) and back to black, the temptation would be to increment each step 10.6666 (255 divided by 8), rounding to nearest whole value at each step. And while this is certainly one approach, it won’t look right. What you’ll get with this is short blacks, quick fades, and long reds. This is because the brightness control on the LEDs is a linear PWM value, but our eyes do not have a linear response to brightness. This is the visual equivalent of the whole how-many-bits audio issue.

We want a smooth, even fade from black to red and back, so we need to adjust our values to emulate the response curve of human vision. This is a power function, not quite a logarithmic curve. I went with a 1.1 power curve, where each value is 1.1 times the one before. If you do this starting at 1 and multiply by 1.1, it takes 558 steps. 559 including zero. If you round each of these steps, you see a lot of repeated values at the low end, but gaps between values at the high end. You can then subsample this list of values into any number of steps you want. This is called a lookup table, and it is very helpful in situations like this where you can pre-calculate values so you don’t have to compute them repeatedly.

I ended up with the following lookup table for the fade up (and the reverse for the fade down):

  • 0
  • 1
  • 2
  • 2
  • 2
  • 3
  • 4
  • 5
  • 6
  • 8
  • 10
  • 12
  • 16
  • 20
  • 25
  • 31
  • 40
  • 49
  • 63
  • 78
  • 99
  • 126
  • 157
  • 199
  • 255

These values could possibly use some tweaking, but they look pretty decent. The curve ends up looking like this:

Luminance Power Curve

Continued in part 3.

[Updated 2011-01-03 to fix power curve graph]

Post a Comment

Your email is never shared. Required fields are marked *