ShiftBrite Not Right

Today I built a Boarduino and the example sketches are working fine. For my first project I wanted to control some ShiftBrite LEDs. When I upload the sample program which (I assume) cycles through red, green & blue, the ShiftBrite does light up, but it it just sorta flickers for a few seconds, then stays steady white for a few seconds, repeat ad nauseum.

I've tried 2 different ShiftBrite modules and get the same behavior.

So I tried creating my own little program to read from the serial monitor and manually control RGB. If I'm setting it to "all green" it stays steady white. All red or all blue just sorta flickers white. Code is below.

Any ideas? Maybe I've not wired/soldered my Boarduino correctly?

I'm a programmer, not a hardware guy, so please keep my ignorance in mind. :slight_smile:

int datapin  = 10; // DI
int latchpin = 11; // LI
int enablepin = 12; // EI
int clockpin = 13; // CI
unsigned long SB_CommandPacket;
int SB_CommandMode;
int SB_BlueCommand;
int SB_RedCommand;
int SB_GreenCommand;

int val;

void setup() {
   Serial.begin(9600);
   pinMode(datapin, OUTPUT);
   pinMode(latchpin, OUTPUT);
   pinMode(enablepin, OUTPUT);
   pinMode(clockpin, OUTPUT);

   digitalWrite(latchpin, LOW);
   digitalWrite(enablepin, LOW);
}

void SB_SendPacket() {
   SB_CommandPacket = SB_CommandMode & B11;
   SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_BlueCommand & 1023);
   SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_RedCommand & 1023);
   SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_GreenCommand & 1023);

   shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 24);
   shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 16);
   shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 8);
   shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket);

   delay(1); // adjustment may be necessary depending on chain length
   digitalWrite(latchpin,HIGH); // latch data into registers
   delay(1); // adjustment may be necessary depending on chain length
   digitalWrite(latchpin,LOW);
}

void loop() {
    if (Serial.available()) {
        val = Serial.read();
        if (val == 'r') {
            SB_CommandMode = B01; // Write to current control registers
            SB_RedCommand = 127; // Full current
            SB_GreenCommand = 0; // No current
            SB_BlueCommand = 0; // No current
            SB_SendPacket();

            SB_CommandMode = B00; // Write to PWM control registers
            SB_RedCommand = 1023; // Maximum red
            SB_GreenCommand = 0; // Minimum green
            SB_BlueCommand = 0; // Minimum blue
            SB_SendPacket();
        }
        if (val == 'b') {
            SB_CommandMode = B01; // Write to current control registers
            SB_RedCommand = 0; // No current
            SB_GreenCommand = 0; // No current
            SB_BlueCommand = 127; // Full current
            SB_SendPacket();

            SB_CommandMode = B00; // Write to PWM control registers
            SB_RedCommand = 0; // Minimum red
            SB_GreenCommand = 0; // Minimum green
            SB_BlueCommand = 1023; // Maximum blue
            SB_SendPacket();
        }
        if (val == 'g') {
            SB_CommandMode = B01; // Write to current control registers
            SB_RedCommand = 0; // No current
            SB_GreenCommand = 127; // Full current
            SB_BlueCommand = 0; // No current
            SB_SendPacket();

            SB_CommandMode = B00; // Write to PWM control registers
            SB_RedCommand = 0; // Minimum red
            SB_GreenCommand = 1023; // Maximum green
            SB_BlueCommand = 0; // Minimum blue
            SB_SendPacket();
        }
    }
}

I figured it out -- I was powering the ShiftBrite directly from a power supply, not from the Boarduino. I ran power from the Boarduino and now it works. Wooohooo!

Now that I think about it, it makes total sense. How else would it control the current? Now I just gotta figure out how to do this with external power since I need to control 4 ShiftBrites...

You'd typically not want to play with the current control registers once you've set them. They're used for tuning the various colors; full brightness would be 127 in each.

The PWM registers are the ones you use to change colors. Your program seems to be trying the right things.

What I would do is get the ShiftBrites working with the sample program first. I'd suspect that you have a wiring problem; make sure the signal wires are all correctly attached, and that your Arduino ground is connected to your external power supply ground (important!). Also, make sure you're powering the ShiftBrite chain from something other than Arduino's 5 volts. You really want something between 5.5 and 9 volts.

Another customer graciously wrote a ShiftBrite library and uploaded it into the Arduino playground. That might make things even easier.

Edit: you self-replied! But the power issue still stands...a decent power supply is good. You can also try adding a 10uF capacitor across the power supply rails.

Thanks for the response!

OK, I've made changes to how I'm setting the current. Wow, these things really are bright.

I tried playing with the ShiftBrite library, but had compilation problems with that. Now that I feel a little more on my feet, I'll give that a go again.

Thanks so much for making the ShiftBrites by the way. I've gone from zero knowledge to controlling the color of a light source since coming home from work. That is awesome.

Now I'm off to figure out how I mix the USB Boarduino with an external power supply...