Jellyfishin’, or, pretty lights

If you’ve got an Arduino, a DMX512 control shield, and some lights that are DMX512 controllable, try this effect out. (The variables are called “JellyFish” because I was using it with an American DJ Jellyfish.)

The Jellyfish can be put in a 28 channel DMX mode where each channel sets the brightness of one of its 28 blocks of color or white LEDs.

The effect of running this code should be that you get a cool display of each light turning on then fading out. Every number of iterations set by jellyFishAddRate, one of the lights will be randomly selected and maxed out, then continue to fade back down. It’s a really nice looking effect and would look pretty awesome on a linear array of individually addressable lights. The same effect should work well on other things like addressable LED tapes and ‘smart’ pixels/Christmas lights, etc, with appropriate drive method.

#include <DmxSimple.h> 
// import the DmxSimple library, of course

int jellyFish[28]; // This array will store the brightnesses
int jellyFishBase=1; // dmx512 base address for da fish
int jellyFishFadeRate=19; // Higher = slower
int jellyFishAddRate=84; // same deal
int jellyFishAddCount;
int jellyFishFadeCount;

void setup() {
jellyFishAddCount=0;
jellyFishFadeCount=0;
 DmxSimple.usePin(3); // this is the data output pin on the shield you're using. if you need to enable the transmitter with another pin, don't forget to DigitalWrite it HIGH!

 /* DMX devices typically need to receive a complete set of channels
 ** even if you only need to adjust the first channel. You can
 ** easily change the number of channels sent here. If you don't
 ** do this, DmxSimple will set the maximum channel number to the
 ** highest channel you DmxSimple.write() to. */
 DmxSimple.maxChannel(42);
 // Turn on the lights.
 int i;
 for (i=0; i<28; i++) {
 jellyFish[i] = 255;
}

}

void loop() {
 jellyFishFadeCount++;
 jellyFishAddCount++;
 if (jellyFishAddCount > jellyFishAddRate) {
 jellyFish[random(28)] = 255;
 jellyFishAddCount=0;
 }
 if (jellyFishFadeCount > jellyFishFadeRate) {
 jellyFishFade();
 jellyFishFadeCount = 0;
 }

 int i;
 for (i=0; i<28; i++) {
 DmxSimple.write((jellyFishBase + i), jellyFish[i]);
 }
}

void jellyFishFade() {
 int i;
 for (i=0; i<28; i++) {
 if (jellyFish[i] > 0) {
 jellyFish[i]--;
 }
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *