Tall Floor Lamps as Lava Lamps

As discussed here, I’ve got a pile of lamps in progress. Lamp #1 is now built. I’ll post some photos shortly.

Cost:

  • ~$30 for the lamp. Varies by design, deal, etc, between $25 and $40
  • ~$17 for the LEDs - 300 ws2812 in 5m strip, non waterproof, with adhesive backing
  • $1 for a pool noodle (runs up the center of the lamp, leds wrap around it)
  • $12 for 5v 8a power supply
  • Pixelblaze v3 + Sensor Board (Might be replaced by a v2, or a esp32 running WLED)

Doing it as a 3D map has proven interesting, and as I load up fun patterns in 2D, I’m reminded both how easy it is to convert, and how different 3D is

Often, I just can add a few lines like:

export function render3D(index, x, y, z) {
  render2D(index, x, y)
}

and it’ll at least try to do something. Not always what I expect.

I’ll do some examples/videos too, as I port patterns, and figure out new and fun ways to make this high tech lava lamp do all the things.

So I’ve got some code I found, built in JS that works in a browser (it uses webgl for display, but that’s removable, and it uses some JS features we don’t have that I’ll have to work around (like array push)), but the results? That looks right. And of course, I’ve done the research into what the physics of a lava lamp is, and how it works. And also of course, the code that “looks right” isn’t actually “right” and doesn’t really do a lava lamp ‘right’, but then it looks right… except now that I look closely, all I can see is the wrong. Sigh.

I also found some code that should be able to do it the right way, but of course, will it look right, and run fast enough?

The ‘looks right, does it wrong’ code: https://scruffynerf.github.io/lava-lamp/
Code that should do it, but who knows: Fluid Dynamics Demo

Yes, I could do metaballs, and fake it all. But what’s the fun in that?
I learned, among other things, that Cloudflare uses Lavalamps in it’s network.

The right way: you need to track the temperature of the ‘wax’ particles, so that their density rises and falls above and below 1 (the density of water). The cheating code looks at the temperature of where the particle is, and ‘bumps it faster’, but then there is no heat exchange between particles (which is what happens in real life). Yes, motion is energy, as is temperature (also energy), but the end result look incorrect, despite how much it looks right in so many other ways. You could even ‘cheat’, and just alter density directly from the temperature, so long as in some way, you do things like having particles equalize density (if you push two together, they should do that, not bounce off each other.). Density is what makes it rise/fall, relative to the water. Never mind surface tension, and more factors unthought of so far.

And if all of the ‘lava lamp’ code for LEDs out there cheats, then doing it the right way seems like a worthy challenge.

1 Like