ITP Blog

Light and Interactivity

Week 2

Observing how a candle light is and trying to recreate that using a neopixel didn't sound so challenging at first but the more I paid attention to how candle lights work the more I realized how hard it is to recreate that using numbers. And I think our perception of how candle light is is different to how it actually is, in real life it's mostly static with slight movements (if it's in a room with little to no air circulation) but our (or rather my) perception of it has more movement and more flickering.

Making the candle

I used the NeoPixelTester to test the individual pixels, and then duplicated the code and started going from there, I changed the color values to ColorHSV so that I could easily sweep between yellow and light orange (as discussed in the class) I also played a lot with the saturation and value numbers to get a more white-ish shade rather than colors, because the thing with candle light is that the edges look more yellow than the inside. For the hue value, I divided the pixels to two sides, I used three values for each side and used a simple linear interpolation function to sweep between the three values randomly. I also added a counter variable so that it would only change the value at a certain rate and it would allow the actual sweep to be visible:

float vals1[3] = {3000.f, 3500.f, 4500.f};
float vals2[3] = {2900.f, 3200.f, 3300.f};
float changer1 = 3000.f;
float changer2 = 3000.f;
int counter = 1;

float lerp(float a, float b, float t) {
  return (1.0 - t) * a + t * b;
}

void loop(){
  counter++;
  if (counter == 30) {
    changer1 = vals1[(int)random(0, 3)];
    changer2 = vals2[(int)random(0, 3)];
    counter = 1;
  }

  h1 = lerp(h1, changer1, .02);
  h2 = lerp(h2, changer2, .1);
}

The strange thing was that I could clearly see a subtle change in color with the LEDs (which is what I wanted rather than a stuttering and flickering effect) but the camera wouldn't capture it, maybe it has something to do with the framerate, so I adjusted the values until I could see the change in color on camera (still more subtle than with my eyes).

I think I could keep readjusting the values and would never be fully satisfied, but for now I think it's close to a flame dancing.

For the container of the candle, I recycled stuff from the junk shelf and put them together like a minature bonfire kind of vibe. I used circular laser-cut acrylic pieces for diffusing the light.