Really? The world needs another Lava Lamp? Yes it does.
Using just two LED’s, for top and bottom of lamp, we’re simplifying to one blob of lava rising and falling. The brightness can be adjusted in the define statement. Other defines adjust the speed. The listing shows how to speed it up to confirm the effect, then slow it down.
A lava lamp in most scenes would be tiny. You may need micro LED’s to keep the wiring trim, but a visual test can be made with 3mm or 5mm LED’s. The light of the LED’s should overlap and diffuse into one another so that it doesn’t look like two separate light sources, but one moving up and down. The lamp would not need to be too bright. Darkly smoked diffused glass would help. But excessive dimming of the LED’s using Theme Designer could lose the smooth fading.
It’s a long listing so here’s making it easy. There are two versions: Fast and cute or slow and realistic. Comment out the appropriate lines as indicated to make your choice. The editor in Sequence Composer has buttons that comment and uncomment many lines at once. As listed, it is fast and cute.
//Lava Lamp using two LED's //Depicts blob of lava rising, falling randomly //chn1 = low led, chn2 = high led ... powers up on chn1 //This breaks down into four pieces of code // 1) blob is heading lower at low speed // 2) blob is heading higher at low speed // 3) blob is heading higher at moderate speed //Blobs move slowly, so we can interrupt & reverse them before they reach the ends //Or they can linger there longer //uncomment these defines for 10x fast, cute version //times may need adjusting together define warmUpTime 0.5s //Initial warmup. Max 150s, but who can wait? define warmUpRiseTime 2s //very slow initial rise define riseFallSlowTime 1s //blob slow speed of rising and falling define riseFallModerateTime 0.6s //blob moderate speed " " define halfMinTime 0.05s define minTime 0.1s //min before change in direction define varyTime 0.05s //variable time before change in direction //uncomment these defines for slow, realistic version //times may need adjusting together //define warmUpTime 5s //Initial warmup. Max 150s, but who can wait? //define warmUpRiseTime 20s //very slow initial rise //define riseFallSlowTime 10s //blob slow speed of rising and falling //define riseFallModerateTime 6s //blob moderate speed " " //define halfMinTime 0.5s //define minTime 1s //min before change in direction //define varyTime 0.05s //variable time before change in direction //Should not blink off entirely define BlobPresent 100% //brightness of blob define BlobAbsent 4% //residually glows at each end, even if blob absent //initialize chn1 = fade from 0% to BlobPresent for 200ms //incandescent light turns on chn2 = fade from 0% to BlobAbsent for 200ms @+warmUpTime //wait for lava to warm up //lava slightly warmed up, first rise is very slow chn1 = fade to BlobAbsent within warmUpRiseTime chn2 = fade to BlobPresent within warmUpRiseTime //perhaps 1/4 rise @+warmUpTime //wait again as slightly warm lava rises somewhat lingerAtWarmUp @+varyTime //wait a random time longer go to lingerAtWarmUp with 95% chance //We don't know how high the lava got by now //Fade To statements will smoothly work with that //now jump into the slow lava movements, which is still faster than warmup go between slowRise2 and slowFall2 //it falls or rises slowly 1st time //random jump table //either continues or reverses blob //these are for the Go Between label1 and label2 statements //normally equally likely alternatives, we have to balance rising //with falling. Extra labels double or triple the probability moderateRise Go to blobRisesModerately //rises faster, needs less time slowRise2 Go to blobRisesSlowly slowRise Go to blobRisesSlowly //using two labels doubles this probability slowFall3 Go To blobFallsSlowly slowFall2 Go To blobFallsSlowly slowFall Go To blobFallsSlowly //using three labels triples this probability //Now start rising and falling //bring blob high slowly blobRisesModerately chn1 = fade to blobAbsent within riseFallModerateTime chn2 = fade to blobPresent within riseFallModerateTime //rise moderate speed @+halfMinTime lingerAtModerateRise @+varyTime go to lingerAtModerateRise with 80% chance //loop perhaps 5x go between moderateRise and slowFall //done, move blobs randomly again //bring blob high slowly blobRisesSlowly chn1 = fade to blobAbsent within riseFallSlowTime chn2 = fade to blobPresent within riseFallSlowTime //rise slow speed @+minTime lingerAtSlowRise @+varyTime go to lingerAtSlowRise with 90% chance //loop perhaps 10x go between moderateRise and slowFall //done, move blobs randomly again //bring blob high slowly blobFallsSlowly chn1 = fade to blobPresent within riseFallSlowTime //fall slow speed chn2 = fade to blobAbsent within riseFallSlowTime @+minTime lingerAtSlowFall @+varyTime go to lingerAtSlowFall with 90% chance //loop perhaps 10x go between moderateRise and slowFall //done, move blobs randomly again
A small self critique: The slow rise and moderate rise speeds are not that distinguishable. The code could have been simplified to slow only, in retrospect.