Easy Peasy RGB LEDs - the holy grail!

Whew..time constraints!
Here's some code for for the strips in the mean time.
Library is coming....

// Data is clocked out to leds and each LED cascades data to the next LED
// 1 Byte for each LED.
// Bit 7 first , bit 0 last
// bit 7 = Data is latchable.
// bit 6 = Fader double speed
// bits 5-4, 3-2, 1-0 are values for green, red, blue
// meanings as follows:
// *       00 - LED off
// *       01 - LED on (max bright)
// *       10 - LED fade up   (start at min bright)
// *       11 - LED fade down (start at max bright)
// eg
// 10010000 = RED on full
// 10110000 = RED on full, then fade down by toggling S pin.


// Set which pins you will use to connect to the LED strip.
#define SIPIN 2
#define DIPIN 3
#define CLKPIN 4
#define LATCHPIN 5

#define LEDS 20    //Set this to the number of LEDs in your strip

// Here is a buffer of values to send to the LEDs
char Display[LEDS];

void setup()
{
  Serial.begin(9600);
 
  //Set up our pins to connect to the LED strip.
  pinMode(SIPIN, OUTPUT);
  pinMode(DIPIN, OUTPUT);
  pinMode(CLKPIN, OUTPUT);
  pinMode(LATCHPIN, OUTPUT);
  digitalWrite(SIPIN, LOW);
  digitalWrite(DIPIN, LOW);
  digitalWrite(CLKPIN, LOW);
  digitalWrite(LATCHPIN, LOW);
 
}  


void SetLed(uint8_t Led, uint8_t Color)
{
    //This will send the data to set an individual LED, no effect on any others
    //L2ggrrbb
    uint8_t i;
    uint8_t x;
 
    x = LEDS - Led; //How many to clock out before we send this one

   for(i=0 ; i < x ; i++)
   {
    SendByte(0); 
   }
  
  //               L2ggrrbb
  SendByte(Color);
  while(i++ < LEDS)
    SendByte(0);
  latch(); 
}

void sPulse()
{
  //Pulse the S line on the LEDs. This will make any LEDs that are fading do their thing.
  //If the double speed bit IS set then two fades will occur. Once each time teh pin is inverted.
  
  digitalWrite(SIPIN, !digitalRead(SIPIN));
  delayMicroseconds(1000);
  digitalWrite(SIPIN, !digitalRead(SIPIN));
  delayMicroseconds(1000);
}

void SendByte(unsigned char it)
{
  //Send out one byte, don't forget to LATCH it by calling
  //Note that for LARGE number of LEDs you may need to slow things down a little here.  
  digitalWrite(CLKPIN, LOW);

  char x;
     for(x=0;x < 8; x++)
    { 
    if(B10000000 & it)
      digitalWrite(DIPIN, HIGH); 
    else
      digitalWrite(DIPIN, LOW); 
    it = it<<1;
    digitalWrite(CLKPIN, HIGH);
    digitalWrite(CLKPIN, LOW);

    }
}

void latch()
{
  digitalWrite(LATCHPIN, HIGH);
  delayMicroseconds(1);  // spec sheet specifies minimum latch pulse of 1us
  digitalWrite(LATCHPIN, LOW);
}

void runfader(int y, int d)
{
  //Pulse the fader y times with delay d between each pulse
  int x;
  for(x=0;x<y;x++)
  {
    digitalWrite(SIPIN, LOW);
    delay(d);
    digitalWrite(SIPIN, HIGH);
    delay(d);
  }
}



void SendDisplay()
{
  //Send out the global array of bytes and then latch them in
  int x=180;
 while(x > 0)
  {
    SendByte(  Display[--x]);   
  }
  latch();
}

void setSection(int startled, int endled, char ledvalue)
{
  //Set a range of LEDs in the memory buffer.
  //Don't forget to call SendDisplay to send the buffer to the LEDs once done!
  while(startled <= endled)
  {
    Display[startled++] = ledvalue;
  }
}




void loop()
{
  int looper;
  
  SendByte(B10010000);
  latch();
  delay(20);
  
  // Send a blue LED marching down the strip.
  for(looper=0;looper < LEDS;looper++)
  {
    SendByte(B10000000);
    latch();
    delay(20);
  }

  // Set ALL the LEDs in the strip to GREEN, then fade down at double speed.
  for(looper=0;looper < LEDS;looper++)
  {
    SendByte(B11000011);
  }
  latch();
  runfader(64,10);


  // Using buffer to create values for LEDs before sending them
  setSection(0,LEDS-1,0);          //Clear buffer
  setSection(0,6,     B10010000);  //Set a blue section
  setSection(7,12,    B10000100);  //set a red section
  setSection(13,LEDS-1,B10000001); //set a green section
  SendDisplay();                   //send the buffer to the LEDs..voila!
  delay(1000);

  
}

Another update on my experience with these lights.

The above code worked to control the strip - thanks blip!

  • And the lights are MUCH brighter than I thought they would be.

I am not sure if this is a suggested use for the pixel / dome LEDs but I was able to get the 8mm and 20mm (5v) and the dome (12v version) all working together with only 2 pins total (daisy chained).

Of course only the data wires (yellow/green) were daisy chained to the 12v dome, which gets it's own 12v power. The 20mm and 8mm could be daisy chained naturally, power and all.

While all three of these LEDs have different RGB orders, the chips appear to be same and the daily chaining worked great.

I can't say enough good things about my first experience with the sample selection ordered. Thanks for the "out of box" solutions for individually controllable rgbs - this is the holy grail and testing shows it is a reality!

Bump for Bliptronics...

and to link to my exhibition review. Works great blip and took 13 days to get to the USA!
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278878251

Hmm
Aus pprice is $2.31 for cheapest and $5.80 post so $108.20 for 40

Thats pretty bloody expensive
Any alternatives , discounts for members , free samples ?

April,

IDK, I priced it out and by the time I bought RGB LEDs, the PWM driver chips (that everyone has on backorder), got wire and attemped to package them I think Bliptronics was cheaper. I intended to make them myself but even on ebay 25 LEDs was going to be $25 and the chips that everyone uses for LED control are $5 each and on back order.
Rogue

I agree that they may not be the "hands down" most inexpensive option, but after adding in my time and other materials, it was the right choice for my project. I have implemented many a few options and they were very time consuming and pretty costly in the end.

So while on the surface they may seem "really high" .. they are actually not so bad when you consider the alternatives.

Happy RGBing