Supports a standalone single ShiftBrite, as well as chains of multiple ShiftBrites.
The ShiftBrite module works best when it powered by a 5.5-9V DC power supply. So typically you'll want to use a different power source to that powering the MSP430. Ensure the ground of the ShiftBrite supply and MSP430 supply are connected.
Connecting the ShiftBrite(s) requires 4 free pins on Port 1 of the MSP430 (Data, Clock, Latch and Enable). The ShiftBrite contains 'In' and 'Out' versions of these. The MSP430 should be connected to the 'In' side of the ShiftBrite.
Multiple ShiftBrites can be chained together by connecting the 'Out' pins to the 'In' pins of the next module in the chain.
1) Allocate a global
2) At startup, call
shiftbrite_init() function, passing in which pins the first module in the chain is connected to.
shiftbrite_init(&sb, BIT4, // Data pin : 1.4 BIT5, // Latch pin : 1.5 BIT6, // Enable pin : 1.6 BIT7); // Clock pin : 1.7
3) Enable the ShiftBrite:
4) For each module in the chain, call
load the data into the module. Each call will shift all the
values to the next module in the chain (a FIFO queue), so you
need to load the values of the furthest module first.
If there's only one module, you need only call this once.
The RGB values should be in range 0-1023.
// Assuming there are 3 modules in the chain shiftbrite_rgb(&sb, 1023, 0, 0); // Set furthest to RED shiftbrite_rgb(&sb, 0, 1023, 0); // Set middle to GREEN shiftbrite_rgb(&sb, 0, 0, 1023); // Set closest to BLUE
5) 'Latch' the data. This sends a signal to each ShiftBrite that the data has been fully loaded and they should update the LEDs to the new values.
6) Yay! Light!
Other things you should know:
The ShiftBrite modules can have the overall light levels configured (Dot Correction) as well as the PWM clock speed. See
The ShiftBrite modules can be enabled/disabled quickly (i.e. turned on/off without having to reload the buffers). See
Q: Can this be used with the MSP430 Launchpad?
A: Yes! See the example directory for an example, complete with wiring. What a fine way to spend $4.30.
Q: Can this work directly with the Allegro A6281 LED Driver?
A: Yes! This is basically what the ShiftBrite is. Just pre-soldered. You try soldering one of these ICs - it's really tricky!
Q: Can't I just drive an RGB LED directly from the MSP430? What's the point of the ShiftBrite?
A: Sure you can. But you'll need some resistors and have to handle the PWM timers yourself. Joby Taffey has a good tutorial on building a Launchpad RGB Lamp using the raw components. The benefit you get from the ShiftBrite (well, the Allegro A6281) is you can easily drive brighter LEDs from a separate power source (which would involve a power regulator, transistors, resistors, capacitors, etc) and chains of many indepenently controlled LEDs from only 4 pins.
Q: Do I have to use the enable pin and
A: Nope. If you want to can wire the ShiftBrite enable pin directly to the ground. Then you don't need to call enable()/disable().