Programmable Task Lighting with RGB LED's

Hello~

This is my first post to the forum, although I've used the Arduino on several projects over the past 2 years.

I have received a commission to design and develop a set of task/shop lights for an art installation opening the first Friday in February, and I want to use the Arduino to control them. This is my first attempt at controlling lights, so I am looking for some guidance from the collective wisdom on this forum.

Here is the set up:

Each lamp must be bright enough to illuminate the space so someone could draw or write or sew or whatever. It doesn't have to be super-bright, just enough to see and work comfortably. Ideally, we will have 8 of these lights around a space of 25' x 50'.

The lights should be RGB LED's, since the color needs to shift subtly (daily) from blue(ish) to red(ish) hues over a span of six weeks. I have not decided yet whether to use Pure Data to control this via computer, or to hard code the arduino using the date/time libraries.

My main questions are these:

-What LEDs would be best suited to this task? (I liked the ShiftBrite, but these won't be available in time for me to use since they are out of stock.)
-Is it possible to control all 8 lamps via one arduino? If so, how is the best way to do this?
-What other components will I need to do this besides an arduino and the LEDs?
-If possible, the collective who hired me would like to have 4 different mappings on the color transitions Could I run these all on the same arduino, or would I need more than one?
-I imagine that these higher watt LED's will need more power than the arduino could provide, is this difficult to wire or is there some straightforward information on this?
-Are there any particular pitfalls that someone with experience in this topic could relate to me that I need to be aware of?

Thanks in advance for any suggestions/help you may offer. I'm learning a lot about electronics on my own and don't have any clear teachers/mentors to assist me. Please let me know if I need to clarify more about this project.

~Kyle

You need to determine how many lumens are required for the task and
then try to determine an appropriate number of LEDs. You could hang
a few light bulbs to estimate the lumens. Take a look in the LED
datasheets to estimate the number and power of LEDs.

What is the distance between the lamps? Each lamp will have to have
its own DC power supply. If you use a single Arduino you need to be
careful of communication cable length. An Arduino for each lamp could
be a lot easier.

You will need some sort of LED driver board. Since you are short on
time you may have to buy one. You could look at the National
Semiconductor or Linear Technology LED driver demo boards. If you want
to build an LED driver board for high power LEDs I would use current
sinks. I have a current sink schematic at Loading...
(scroll down to the load cell). I would build one circuit for each
color. You will still need a DC source for the LEDS.

The heatsinking will be the most difficult part of this. You need to
remove heat from the LED driver and heat from the LEDs. IIRC Luxeon
sells strips of high power LEDs (alternating RGB) that are mounted on
metal core PCBs. Purchasing a strip of LEDs could be a big time
saver.

(* jcl *)

Thanks for your quick reply! I've been having all sorts of issues w/ a near-dead computer, so I've taken a brief break on the project and am now jumping back in.

I just found out that the ShiftBrites are back on sale, and they are already connected to LED drivers and very simple to daisy chain to the arduino. I believe they also have a heat-sink, but if not, it's probably not too hard to attach one, right?

I'm thinking of forgoing all computer input and doing an arduino for each lamp as you suggested. My only question on that is how difficult it would be to set up a system where it can power down and power up without resetting my arduino program (which has to keep track of date/time in order to have a subtle color shift over 6 weeks). What steps could I take to keep that program on-time without resetting?

I asked my collaborators to take some simple light measurements of the space (using 800 lumen 60W incandescent bulbs) and email me a schematic of the positioning. I'm not sure about the ShiftBrite output yet, but the site has some neat pictures of projects using them and it's promising, not to mention time-saving!

Thanks for your help on this!

~Kyle

I just found out that the ShiftBrites are back on sale, and they are already connected to LED drivers and very simple to daisy chain to the arduino. I believe they also have a heat-sink, but if not, it's probably not too hard to attach one, right?

That sounds like your best bet since you do not have much time. I have never seen a
ShiftBrite so I do not know how hard it is to attach a heatsink. Don't forget that
if you need a good thermal contact between two flat surfaces you will a thin
layer of thermal compound to fill in the air gaps.

I'm thinking of forgoing all computer input and doing an arduino for each lamp as you suggested. My only question on that is how difficult it would be to set up a system where it can power down and power up without resetting my arduino program (which has to keep track of date/time in order to have a subtle color shift over 6 weeks). What steps could I take to keep that program on-time without resetting?

You will either need a battery on the Arduino to keep it running or a real-time clock (RTC) module that has a battery in it. One for each Arduino.

(* jcl *)

Kyle,

I got your email too, but I'll go ahead and answer here for everyone's benefit...

The ShiftBrite is probably not going to be bright enough for task lighting. The LED is 20mA per color, and doesn't require heat sinking; I don't have lumen output but the manufacturer claims 8,000mcd per color at 140 degrees output angle. In dark room, one LED will output enough light to see everything, but definitely not enough light to work without eyestrain.

There are other possibilities I'm prototyping, but they won't be ready in time for your project. In the meantime, you could check out the BlinkM MaxM, which uses 5-chip LEDs per color and has a 40 degree projection angle, resulting in more of a spotlight effect. You could mount some of those pointing at the work areas and probably get enough light; I haven't seen a MaxM in person so I don't know if just one will be enough per area, but two or three should be getting there. It's an effective 1/2 watt per color, so two MaxM devices could be comparable to a 3 watt white LED.

Alternately, you could get a few of these and control them directly from a single Arduino using three MOSFETs: http://www.dealextreme.com/details.dx/sku.14963

Altern-alternately, you could get three of these and control some AC fixtures with colored incandescent light bulbs, from a single Arduino: http://www.quasarelectronics.com/velleman/k8064-dc-controlled-dimmer-kit.htm. It would be inefficient compared to LEDs but you wouldn't have a problem with brightness. Maybe use mostly white and just pull the temperature a little warm or cool with a few colored bulbs.

So the options I'll have available soon, though not soon enough for your project:

ShiftBar: it will control light bars like these http://www.dealextreme.com/details.dx/sku.11304, another forum member was interested a solution for these

MegaBrite: three five-chip LEDs, 140 degree wide angle LEDs

UltraBrite: to be determined, at least three times more power than a MegaBrite

unnamed: controls a single 3W RGB LED

Macegr~

Thanks for your prompt reply! I was waiting on an email and for some reason wasn't notified when you posted to the forum, so I just now saw it.

I appreciate your honesty about your product and it's capabilities. It's good business to recommend other solutions rather than just try to push a sale.

I still am curious about your ShiftBrites however. I saw the LED NYE ball and it looked pretty bright.

Right now my planning has been this: since your can link up to 32 ShiftBrite modules in series powered by one AC adapter, I could try to make each lamp with multiple SB's in series. I want to have 8 lamps made, and the budget is around $1000 max.

In your honest opinion, would I be able to provide enough light with a cluster of SB's per lamp, say between 16 and 32 each lamp? Regarding the output angle, I will most likely use aluminum shop light casings or some other reflective diffuser to focus the light.

What do you think? I'm getting down to my deadline to order parts in time, so I truly value your courtesy, time, and support on this matter.

~Kyle

I will use one arduino per lamp, since I want to skip using computers to control them.

Kyle,

If I thought that ShiftBrites were at least an equivalent solution to products from other suppliers, I would shamelessly promote my own product. However I am pretty sure that, while ShiftBrites are definitely bright to look at and 16 of them will definitely light up a dark room enough to see, they are not really comparable to actual lighting solutions. Think...hmmm...a 25 watt incandescent light bulb from 5 feet away. You will be able to see what's happening but it will not be a bright working environment, there will be eyestrain. A lot of this is due to the wide viewing angle, but creating some kind of reflector strikes me as unnecessary when you can get LEDs that already emit in a narrow angle.

However, your deadline is less than 2 weeks away and you're already out of time for options that require shipping from China, such as the LED bars I suggested. The whole country is having New Year celebrations and nothing will be shipped until February. You might be able to find a faster source. With three or four of those LED bars per station, three MOSFETs, six resistors, and a 12 volt power supply, you would be in good shape and have a decent amount of light. It's still possible to do this if you buy a lot of LEDs and solder up your own arrays, but that will be significant work.

I was going to recommend the MaxM again, but it appears they are out of stock everywhere. For a ready made solution, maybe this eBay auction is a possible option. 8 RGB lamps, DMX controlled, 600 dollars under budget. There is some work with Arduino and DMX, have not tried it so you will need to make sure it's possible.

Or if you really want to use ShiftBrites, I guess I won't argue. If you put 16 of them about 1.5 feet away from something, full-blast they will light up about the same as a typical small fluorescent task light. I have actually had some problems with 32 of them on a single supply, so I don't recommend going for 32 just yet, unless you provide a 6 or 7 volt supply and inject power at a couple points on the chain. Worst case, it will provide some amount of colored lighting effect and you can round it out with some additional lighting, and afterward you have a lot of controllable LEDs to make a pixel wall or something.

I would take at look at Home Depot or Lowes or a commercial lighting store
and see if they have any LED lighting that you could control with a FET.
If the LEDs are powered by a wall-wart you should be in good shape.
I know Home Depot has white LED pucks maybe there are other colors (or you could use a filter). You could go and buy a couple, power them up to the rated current and check the amount of light. Return them if they don't work.

Also checkout http://ledtronics.com and the other LED manufacturers.
Sometimes the LED manufacturer produce packaged solutions.

(* jcl *)

Thanks again to both Macegr and Jluciani for your help on this.

I've decided to go with an order of ShiftBrites that will be daisychained together in series of 16 per lamp. The gallery will have 7 lamps. We will experiment with reflection/diffusion strategies to optimize the light output. If needed, I'll try an additional white light per lamp. Hopefully this won't bleach out the color from the LED's.

I think this will work, since the request is for a low-light setup anyway. As long as people can see enough to get around and maybe read/sew something in close proximity to the lamps, the job will be a success.

Now my main concern is to start prototyping the software that will go on the Arduino. I think an RTC is a bit much for my skill level. What would I need to do to have an external battery power the unit when everything else is turned off? I'm thinking a 9-volt or a watch battery might suffice...but will they last for 6 weeks? I don't want to get mired down in fancy details that are beyond my abilities with such a short project time frame.

Once again, any help on this is greatly appreciated! I am sure to have many questions still once I get to the location with all of my toys strewn about!

~Kyle

If possible post a link to some pictures. I am curious to see the end result.

Doing the clock on the Arduino (with a battery) could save you money but at this point
you need to save time. I would recommend the real-time clock IC that has the battery
built in. Checkout the Maxim website. You just need to wire the IC to the I2C
or SPI port and do reads and writes.

If you decide to try a battery I wouldn't use a 9V battery. With a 5V system 4/9 of your energy is wasted. You need maybe 700 hours of operation (6 * 7 * 16?). Measure
how much current the Arduino draws and calculate the milli-amp hours (mAH).
C-cell is 8350mAH, AA is 2850mAH, AAA is 1250mAH and CR2450 is 600mAH,
9V battery is 625mAH. After the rated mAH the batttery voltage is apx 1/2 its original value.

(* jcl *)

kyleclip: Thanks, and I hope this will work as expected. Definitely feel free to contact me for any hints getting this running.

I think that you could do quite well just using millis() to determine how much time has passed. You'll only be adjusting by a couple bits over the course of a day anyway. There is the possibility of the Arduinos getting out of sync due to variations in clocking, but it may not matter. This assumes you can turn off just the LEDs...or will all power to the room be shut down at night?

An RTC is a possibility. SparkFun has a ready to use module, if a little pricy: http://www.sparkfun.com/commerce/product_info.php?products_id=99 I really did start my next round of products a couple months too late, because one of them actually is a little battery backed temperature-compensated clock module. With the MegaBrite and the RTC module, I could have had a total solution for you. :frowning:

Anyway, consider an RTC per Arduino, or some form of communication between Arduinos with one master Arduino that has the RTC and passes on the info. You might be able to get away with SoftwareSerial and some wires, using a low baud rate at TTL signal levels.

Ok, the ShiftBrite shipment is in and I have been testing over the last few days.

First, I wanted to say thanks to Garrett for offering such an affordable and easy-to-use product. I have been having a moderate amount of sucess with my tests.

One issue that is perplexing me involves my power source to the Arduino. At this juncture, I am doing tests involving 3 SB's in series, with the 5.5 V power supply dedicated to only LED activities. When the Arduino (Duemilanove) is plugged into the USB port, the LED's work as expected.

However, when I attempt to poer the Arduino on a separate 9V, 1000 mA power supply (with the appropriate center-positive 2.5 mm tip), I get a very dim signal to only the first in my series.

I've tested my connections for continuity and they seem fine, especially given that they are running fine w/ the USB power. I've used more than one Arduino running the software and it's a common issue. I really don't want to deal with computers in this installation, so I'd like to use AC/DC power if possible.

What could be going on here?

Also I have an issue compiling the following code. I will post the error messages as well. I'm not sure what to make of this. The project is on a tight deadline now, and I need some wisdom!

#include "ShiftBrite.h"
/*#include <EEPROM.h>
#include <DateTime.h>

#define TIME_MSG_LEN 11 // time sync to PC is HEADER and unix time_t as ten ascii digits
#define TIME_HEADER 255 // Header tag for serial time sync message
*/

void setup()
{
ShiftBrite SB(10); //A ShiftBrite starting on pin 10, assumes the next pins are sequentially going up
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
SB.setPower(127);

// Initialize RGB arrays
int r[] = {457, 493, 526, 542, 566, 586, 614, 634, 662, 682,
710, 722, 742, 750, 762, 771, 779, 783, 791, 799,
803, 811, 815, 823, 827, 831, 835, 839, 843, 847,
851, 855, 859, 859, 863, 867, 871, 871, 875, 879,
883, 883, 887, 887, 891, 891, 895, 895, 899, 899,
903, 903, 907, 907, 911, 911, 911, 915};

int g[] = {622, 614, 618, 622, 626, 626, 630, 634, 634, 634,
638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
638, 638, 638, 638, 638, 638, 638, 638};

int b[] = {983, 959, 927, 903, 875, 851, 823, 795, 762, 742,
718, 702, 682, 674, 662, 654, 646, 642, 634, 630,
622, 614, 610, 606, 598, 594, 590, 586, 582, 578,
574, 574, 570, 566, 562, 562, 558, 554, 550, 546,
546, 542, 538, 538, 534, 534, 530, 530, 526, 526,
522, 522, 518, 518, 518, 514, 514, 509};
}

void loop()
{
for(int i = 0; i < 57; i++)
{
// Pass values to ShiftBrites
SB.setColor(r, g_, b*); // SB #15 (since the data gets pushed through the SBs, the last one is set first)
SB.setColor(r, g, b); // SB #14*

SB.setColor(r, g, b*); // SB #13*
SB.setColor(r, g, b*); // SB #12*
SB.setColor(r, g, b*); // SB #11*
SB.setColor(r, g, b*); // SB #10*
SB.setColor(r, g, b*); // SB #9*
SB.setColor(r, g, b*); // SB #8*
SB.setColor(r, g, b*); // SB #7*
SB.setColor(r, g, b*); // SB #6*
SB.setColor(r, g, b*); // SB #5*
SB.setColor(r, g, b*); // SB #4*
SB.setColor(r, g, b*); // SB #3*
SB.setColor(r, g, b*); // SB #2*
SB.setColor(r, g, b*); // SB #1*_

* delay(60000);*
* }*
}
[/quote]
Here are the error messages:
> In file included from /Applications/arduino-0012/hardware/cores/arduino/WProgram.h:4,
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected )' before 'int'*_</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>_*>*_</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>_*> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected )' before 'int'
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected )' before 'int'*_</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>_*>*_</em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em><em>_*> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected )' before 'int'
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected identifier before '(' token
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected `)' before '(' token
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected initializer before ')' token
>
> /Applications/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared
>
> In file included from /Applications/arduino-0012/hardware/cores/arduino/WProgram.h:6,
>
> In function 'void loop()':
What am I missing here?

Warning: it sounds like you may not have the grounds connected! Please make sure that the 5.5V supply ground is still connected to the Arduino ground, as well as the ShiftBrite grounds. You can (must) keep the 5.5V and 9V positive supplies separated, but the grounds need to be connected for the correct signals to pass through. I hope that no damage has been done yet, another customer burned out some ShiftBrites this way, because the voltage on logic level inputs was incorrect due to lack of a common ground reference.

Regarding code, I think the ShiftBrite library currently needs a little modification before it's optimal for more than a few ShiftBrites. First check your wiring as above and then I'll go over some other code I have for controlling ShiftBrites.

Ahhh...

Yes, my buddy who is a bit keener on the wiring side thought that might be the problem...I have two power supplies connected to two different grounds. So I need to have the power from the 5.5 V adapter the way it is, but then bring the ground to the Arduino? I mean, I will have only one wire (positive voltage) between my SB power supply, and then the SB ground goes into the GND pin of the Arduino and through to the ground of the Arduino power supply?

I will try this. I am exhausted tonight, so will try in the morning.

My code issues are also driving me nuts. The ShiftBrite library is much easier for me to understand and modify than the code you posted...but your code compiles and the other one hangs!!!

I don't quite understand how your code is navigating the chain of SB's. I really want them all to have the same color, and then have that color reference my 3 arrays for RGB values daily, incrementing the arrays one day at a time. I think that the DateTime libary would be nice, even maybe writing something daily to the EEPROM in case of power outage...but we also have a 45 min UPS on hand so that might be overkill...

Thanks again for all of your help, I'm on life support today and am pretty razzed up!

Yes, you would run the positive side of your 5.5V power supply to the V+ line on the ShiftBrites, run the negative side to the GND line on the ShiftBrites, then run GND to the GND on the Arduino.

I can whip up a code example that just gives you a function to set the color of a whole chain of ShiftBrites at the same time. I was also thinking that you could get a much smoother, gradual fade effect by setting some ShiftBrites to the new color before others. For example, if you wanted to change the color by one increment over 8 hours, every 1/2 hour you could set one additional ShiftBrite to the new color.

Anyway I'll first get you set up with a straightforward code example, you'll just have a function to call with the desired color.

Let me get this right: I will keep the ground from the 5.5v power supply to the ShiftBrite chain but also split it to the Arduino? Or do we run the final ground in the chain of ShiftBrites back to the Arduino ground? Also, is there a difference between the GND on the Power pin grid of the Arduino and the GND next to pin 13?

I like that idea of the slow shift...it would be really neat to do that way if we can get a prototype working on a bare bones system that is stable.

I guess I am just having trouble understanding the code, since it deals with shift registers and other stuff that I've never encountered before.

In particular, I have no idea what the function void SB_SendPacket() does exactly, nor how to expand this code to address multiple lights!

I hope that you can get me some example code that I can figure out soon, everyone around here is getting a little jumpy!

Thanks so much again.

~Kyle

Also, it maybe helpful to do a gmail chat with you, if you are up for it. I am kyleklip@gmail.com

~Kyle

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.

Here it is for the curious:

// 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)

~Kyle

How many ShiftBrites did you lose? Will it affect the project very much? Also, I noticed that you have the current control registers set to 64, where 127 would actually be full brightness.