Go Down

Topic: MegaBrite RGB (Read 2026 times) previous topic - next topic

kculm

Hi All,

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

https://www.sparkfun.com/products/10236.

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 .

Code: [Select]
#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);


}



kculm

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.

JoeN

What idiot designed the header angles on that board?
I will never ask you to do anything that I wouldn't do myself.

macegr

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

JoeN


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?
I will never ask you to do anything that I wouldn't do myself.

fungus


What is the point?


You can easily put six of them together in a circle to make a GigaBrite..?
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Hippynerd

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.
https://sites.google.com/site/rgbledcubes

fungus

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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

kculm

#8
Jan 17, 2013, 06:37 pm Last Edit: Jan 17, 2013, 07:02 pm by kculm Reason: 1

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


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... :)
I will never ask you to do anything that I wouldn't do myself.

Hippynerd

#10
Jan 17, 2013, 07:22 pm Last Edit: Jan 17, 2013, 07:28 pm by Hippynerd Reason: 1
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...
https://sites.google.com/site/rgbledcubes

JoeN


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.   ]:D
I will never ask you to do anything that I wouldn't do myself.

fungus

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Hippynerd

Snowflakes make matrices look like squares.
https://sites.google.com/site/rgbledcubes

macegr

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.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy