Hmm. So, you have a rainbowduino, you have a bunch of LEDs, you have worked out how to connect all the LEDs to the board and now it's a matter of writing a nice sketch to run them - is that right?
Or do you need help with mutiplexing the LEDs? Working out what wires go where?
I'm finding three "rainbowduino" products:
Ah - this appears to be the relevant one: Rainbowduino v3.0 | Seeed Studio Wiki . " It can drive an 8x8 RGB Led Matrix or a 4x4x4 RGB LED Cube in common Anode mode. " = seems to be the one you are talking about. Fine. Now … where's the API?
GitHub - unwiredben/Rainbowduino-v3: Support library from Seeed Studio for Rainbowduino v3 board, as used in their Rainbow Cube this looks like the API. I shall snarf it …
Ok, there's some sample code:
for(x=0;x<8;x++)
{
for(y=0;y<8;y++)
{
Rb.setPixelXY(x,y,random(0xFF),random(0xFF),random(0xFF)); //uses R, G and B bytes
}
}
Cooking. Now, you need a function "setSInglePixel" which takes a pixel 0-192 and a value 0-255. Unfotunately, you need to preserve the other two colours of the pixel you are talking to, and there's no 'getPixel' function. No matter - we shall have to do it the hard way:
uint32_t pixels[64];
void setPixel(int pix, byte v) {
int pp = pix/3; // which 'led'
int rgb = pix % 3; // r, g, or b in that 'led'
uint32_t vv = (uint32_t) v << (8 * rgb); // righ-shift the target value;
uint32_t mask = 0xFF << (8 * rgb); // make a 8-bit mask;
vv |= pixels[pp] & ~mask; // preserve the other r/g/b values
pixels[pp] = vv; // save the result
Rb.setPixelXY(pp >> 8, pp % 8, vv); // explain this to the rainbowduino
}
Now, you want to "randomly fade LEDs in and out". Not quite sure what that means.
int led_being_faded = 0;
byte current_value = 1;
void loop() {
delay(10);
if(current_value == 255) {
current_value = 254;
}
else if(current_value == 0) {
current_value = 1;
led_being_faded = random(192);
}
else if(current_value & 1) {
current_value += 2;
}
else {
current_value -= 2;
}
setPixel(led_being_faded, current_value);
}
If that's not what you want, you may have to get a little more specific.