Pages: [1] 2   Go Down
Author Topic: MegaBrite RGB  (Read 1324 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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);
 
 
}

Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What idiot designed the header angles on that board?
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Me. They're...fun!
Logged

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

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the point?

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

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

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: January 17, 2013, 01:02:27 pm by kculm » Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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... smiley
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: January 17, 2013, 01:28:11 pm by Hippynerd » Logged


Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-twist
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

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

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Snowflakes make matrices look like squares.
Logged


SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Pages: [1] 2   Go Up
Jump to: