MegaBrite RGB

Hi All,

I piceked up a Mega Brite RGB (Tiro) From Sparkfun.com

MegaBrite - Straight Headers - COM-10236 - SparkFun Electronics.

The thing is am very new to all this. (about a month) and I am not sure how to use it.

I looked at the example sketch and was able to figure out the PIN's some what. But when I Run it only the Blue and red come on.

Thanks of any help given .

#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI
 
#define NumLEDs 2
 
int LEDChannels[NumLEDs][3] = {0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;
 
void setup() {
 
   pinMode(datapin, OUTPUT);
   pinMode(latchpin, OUTPUT);
   pinMode(enablepin, OUTPUT);
   pinMode(clockpin, OUTPUT);
   SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
   digitalWrite(latchpin, LOW);
   digitalWrite(enablepin, LOW);
 
 
}
 
void SB_SendPacket() {
 
    if (SB_CommandMode == B01) {
     SB_RedCommand = 120;
     SB_GreenCommand = 100;
     SB_BlueCommand = 100;
    }
 
    SPDR = SB_CommandMode << 6 | SB_BlueCommand>>4;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_BlueCommand<<4 | SB_RedCommand>>6;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_RedCommand << 2 | SB_GreenCommand>>8;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_GreenCommand;
    while(!(SPSR & (1<<SPIF)));
 
}
 
void WriteLEDArray() {
 
    SB_CommandMode = B00; // Write to PWM control registers
    for (int h = 0;h<NumLEDs;h++) {
	  SB_RedCommand = LEDChannels[h][0];
	  SB_GreenCommand = LEDChannels[h][1];
	  SB_BlueCommand = LEDChannels[h][2];
	  SB_SendPacket();
    }
 
    delayMicroseconds(15);
    digitalWrite(latchpin,HIGH); // latch data into registers
    delayMicroseconds(15);
    digitalWrite(latchpin,LOW);
 
    SB_CommandMode = B01; // Write to current control registers
    for (int z = 0; z < NumLEDs; z++) SB_SendPacket();
    delayMicroseconds(15);
    digitalWrite(latchpin,HIGH); // latch data into registers
    delayMicroseconds(15);
    digitalWrite(latchpin,LOW);
 
}
 
void loop() {
 
   LEDChannels[0][0] = 1023;
   LEDChannels[0][1] = 0;
   LEDChannels[0][2] = 0;
 
   LEDChannels[1][0] = 0;
   LEDChannels[1][1] = 0;
   LEDChannels[1][2] = 1023;
 
   WriteLEDArray();
   delay(200);
 
   LEDChannels[0][0] = 0;
   LEDChannels[0][1] = 0;
   LEDChannels[0][2] = 1023;
 
   LEDChannels[1][0] = 1023;
   LEDChannels[1][1] = 0;
   LEDChannels[1][2] = 0;
 
   WriteLEDArray();
   delay(200);
 
 
}

My Bad,

After reading more about the sketch in the supplied Doc. All it is supposed to do is blink Red and Blue.

That being said, Now I really need help.

Thanks once more.

What idiot designed the header angles on that board?

Me. They're...fun!

macegr:
Me. They're...fun!

Then I take back the idiot part. And they are fun and interesting. But how doesn't that kill you for using it on a breadboard? It has to make it harder to interface it even on a custom made PCB because it's harder to verify its right before sending it off to be manufactured too. What is the point?

JoeN:
What is the point?

You can easily put six of them together in a circle to make a GigaBrite..?

I really like the hexagonal shape, it tessellates quite nicely, you can make a honeycomb pattern. There are some interesting 3D polygons that you could make with a hexagon. Pentagonal would be real nice for 3D geometric shapes also.

I don't think you'd want to put both sets of pins in a breadboard anyway. One set of pins is just for daisychaining.

macegr:
Me. They're...fun!

I have a Favor, because I am new to all this and I got a lot to learn. Any way you could post or PM me some more Example code. Or explain in a dumbed down version on the code that is in the Doc.

I got some of it figured out. I can make all three LED's blink on and off and dim. But thats all.

Thanks

fungus:

JoeN:
What is the point?

You can easily put six of them together in a circle to make a GigaBrite..?

Buying enough for a gigabrite would get pricy... :slight_smile:

It takes 10 kilobucks to make one gigabright.

edit:
Actually, i guess thats 9.95 Kbucks.

Doh, looks more like 7.96 Kbucks if you get 100 pricing...

4th edit:
2^10, seems appropriate...

Hippynerd:
It takes 10 kilobucks to make one gigabright.

edit:
Actually, i guess thats 9.95 Kbucks.

It sounds like you are using 10^3 as your definition of kilo. It may be 2^10 in this case, but I am not sure. ]:smiley:

I can imagine a big LED snowflake made with those. You couldn't do that with square ones. :slight_smile:

Snowflakes make matrices look like squares.

The plan was to use them with cables and mount them on objects, rather than plug them into a breadboard or solder them into a PCB. Therefore the angled headers seemed less of a problem. We never did a redesign, but making the headers parallel was definitely on the to-do list.

I think the hexagon is better for the sort of things I can imagine doing with them, eg. Arranging them in patterns on walls/ceilings, putting them inside circular light fittings, attaching them to other stuff.

(Trying to connect several of them together on a breadboard isn't anywhere on my list)