Sorry for the late response. I didn't check this thread for a while. (+ it doesnt seem to be subscription of threads here?).
What you say about storing the pattern in an array is correct (not that it's the only way, but it certainly is one way of doing it).
If you have a 16 bit shiftregister, or two 8-bit shiftregisters chained, you need to use the shiftOut() function twice. If you store the pattern as an int (2 bytes), you need to extract one byte at a time from it and feed the shiftOut() function.
If you don't strobe the leds while doing the shiftOut, they will lit up briefly (not visible I'd guess, as it is pretty quick. But I haven't tried this yet in fact) as the bits shift to their position.
Then, after 16 bits are shifted out, you just wait a time equal to some preset framerate. Let's say about 30 frames pr. second, you wait about 1/30 second until you shift out the next pattern.
Or I guess that's far too quick for this purpose when I think about it.. say 1/5th of a second maybe, and you wait about 200 ms until the next pattern. Just experiment with the timings.
Pseudo-ish code:
int dataPin = 12;
int clockPin = 13;
int patterns = 8 ;
unsigned int pattern[] = {b1000000000000001,
b1100000000000011,
b1110000000000111,
b1111000000001111,
b1111100000011111,
b1111110000111111,
b1111111001111111,
b1111111111111111 };
void setup()
{
}
void loop()
{
for (int i=0;i<patterns;i++)
{
uint8_t lowByte = (uint8_t)pattern[i] & 0x00FF:
uint8_t highByte = (uint8_t)(pattern[i] >> 8 ) & 0x00FF;
shiftOut(dataPin, clockPin, MSBFIRST, highByte);
shiftOut(dataPin, clockPin, MSBFIRST, lowByte);
delay(200); // milliseconds
}
}
(Basically wrote the hole thing there?:p Primitive waiting though, but it works)
Not sure uf the typecasting of (uint8_t) is neccessary together with the masking though (masking = AND'ing with 0x00FF = just keep the lowest byte). Experiment
