OK, I think I've got it all figured out and running smoothly.
I was experiencing a lot of grief due to some burnt out ShiftBrites and a fried Arduino (one of my colleagues reversed the polarity on the Arduino power supply).
After swapping for some fresh units and enlisting the extra special voltron force of some local friends/electrowarlocks, things are looking up. Thank God for teamwork!
I was able to figure out how to use the example code posted on the Macetech blog, and modify it. I first tested my color arrays with a quick loop cycling through. My completed code is for a chain of 15 ShiftBrites that will run for 58 days through the "color of the universe" as depicted here (Physics & Astronomy | Johns Hopkins University). I extracted the RGB colors from this image (Physics & Astronomy | Johns Hopkins University) with a quick Processing sketch that wrote the values to text files which I then copied into my arrays.
// Deep Time LEDs
// for spurse installation at Grand Arts Gallery Feb-April 2009.
// Declare variables
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 days = 0; //initialize the day counter
// Initialize RGB arrays
int r[] = {114, 123, 131, 135, 141, 146, 153, 158, 165, 170, 177, 180, 185, 187, 190, 192, 194, 195, 197, 199, 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 217, 218, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 225, 225, 226, 226, 227, 227, 227, 228};
int g[] = {155, 153, 154, 155, 156, 156, 157, 158, 158, 158, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159};
int b[] = {245, 239, 231, 225, 218, 212, 205, 198, 190, 185, 179, 175, 170, 168, 165, 163, 161, 160, 158, 157, 155, 153, 152, 151, 149, 148, 147, 146, 145, 144, 143, 143, 142, 141, 140, 140, 139, 138, 137, 136, 136, 135, 134, 134, 133, 133, 132, 132, 131, 131, 130, 130, 129, 129, 129, 128, 128, 127};
void setup() {
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() {
for(int minutes = 0; minutes < 1440; minutes++) { // count the minutes to a day 1440, mins in a day
for(int seconds = 0; seconds < 60; seconds++) { // count the seconds in a minute, 60 secs in a minute
for(int i = 0; i < 15; i++) { // write to the ShiftBrites every 1/15th of a second (for time keeping ease)
SB_CommandMode = B01; // Write to current control registers
SB_RedCommand = 64; // Full current
SB_GreenCommand = 64; // Full current
SB_BlueCommand = 64; // Full current
SB_SendPacket();
SB_CommandMode = B00; // Write to PWM control registers
SB_RedCommand = r[days]; // red
SB_GreenCommand = g[days]; // green
SB_BlueCommand = b[days]; // blue
SB_SendPacket();
delay(66); // integer portion
delayMicroseconds(667); // gotta fudge the decimal
} // exits every 1 second
} // exits every 1 minute
} // exits every day
days++;
if(days >= 57) {
days = 57;
}
}
Thanks again to everyone for the help! If you want to see the exhibit in action, visit Grand Arts Gallery in Kansas City from February 6 to April 4th, 2009. (Grand Arts)