Shiftbrite question

I have two shiftbrites with powered by an external supply and hooked to an Arduino Duemilanova.

I have tried several sample codes and I am unable to get anything but rapidly flashing dim lights.

I have tried the code below and I only get a dim blink every 2 seconds. This makes me think that the shiftbrite requires that I continually pump it new values to keep it lit up. I was under the impression that the light would stay the last color that you send it.

If I remove the delay, I get rapid dim blinks and still no good color out of the LED.

Here is my 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(2000);

 
 
}

Thank you in advance for any support!

Do you have the ShiftBrite ground, the external supply ground, and the Arduino ground all connected together?

OMG that fixed it.

I can't believe that I overlooked that.

THANK YOU!!!!

I'm so glad to see that everything actually is working how I expected it to work. :slight_smile:

I have a bit more confidence in my sanity now.

Glad to hear it's working...I knew almost instantly what was wrong because someone else asked the same question in these forums a few hours ago: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1268933348