RGB Module

Our range of tiny modules are designed to make it easy for you to quickly add functionality to your projects. [Module List]
Post Reply
SwiftBrookee
Posts:1
Joined:Sat Sep 15, 2012 9:35 pm
RGB Module

Post by SwiftBrookee » Sat Sep 15, 2012 9:46 pm

Hi all

I have two Freetronics RGB Modules and would like to keep them seperate and not daisy chain them together. I would like to use the code supplied by Freetronics to send different colour programs to each RGB module.
Does anyone know how i can change the code to incorporate two colour programs?

Any help would be much appreciated!

csconsulting
Posts:71
Joined:Fri Sep 21, 2012 7:22 am

Re: RGB Module

Post by csconsulting » Tue Sep 25, 2012 7:23 am

Well you could still daisy chain them and control them seperately.

the other thing you can do is is use the demo code, but add a digit to each variable.
so CK would be CK1 and Ck2, and then essentially redo the example twice in side the same program.

A bit messier though.

the RGB modules are easily daisy chained however.
you just post data to the first chip, then send out another set of data, which will overflow into the second chip automatically. If you wait a few microseconds then, both chips will then output those values to the RGB led and you have your seperate display.
I have some code that can i can show you that does this kind of thing if you like.

quadtiger
Posts:2
Joined:Thu Oct 25, 2012 8:17 am

Re: RGB Module

Post by quadtiger » Thu Oct 25, 2012 8:20 am

csconsulting wrote:I have some code that can i can show you that does this kind of thing if you like.
I would love to have a look at this code if you don't mind! I"ve just daisy chained a second RGB Led and would love to see how to control it separately.

csconsulting
Posts:71
Joined:Fri Sep 21, 2012 7:22 am

Re: RGB Module

Post by csconsulting » Mon Nov 05, 2012 9:29 am

I have attached the sub program i use to write to my LED.
What you do is do "post_frame" for every led, one after the other.. like this
Post_Frame( long RGB1);
Post_Frame( long RGB2);
Post_Frame( long RGB3);
Post_Frame( long RGB4);

for each LED in your string.

At the end, delay(1); which will let the leds push their colours to the actualy rgb module.
repeat as required.

Code: Select all

void Post_frame (long colour) {
  for(byte color_bit = 23 ; color_bit != 255 ; color_bit--) {
    //Feed color bit 23 first (red data MSB)

    digitalWrite(CKI, LOW); //Only change data when clock is low
    delayMicroseconds(10);
    long mask = 1L << color_bit;
    //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit.
    if(colour & mask) 
      digitalWrite(SDI, HIGH);
    else
      digitalWrite(SDI, LOW);
    delayMicroseconds(10);
    digitalWrite(CKI, HIGH); //Data is latched when clock goes high
  }
  delayMicroseconds(10);
  //Pull clock low to put strip into reset/post mode
  digitalWrite(CKI, LOW);
  delayMicroseconds(500); //Wait for 500us to go into reset
}
//==================================================================================

Post Reply