Hi, i have made a circuit for 8 LED that uses a shift register and works (Not my code by the way) What i want to do is add an additional 8 LED on a second shift register and i have built the circuit after finding out how to physically add the second shift register. What i have no idea about is what changes to the code below i need to make to 'access' the second shift register. I'm guessing that even if i get the new code the second set of LED will flash in the same sequences as the first?
My next step once i get both sets of LED working off the 2 registers would be to have a second matrix for the second set of LED, is that possible so that i get two different arrays going?
thanks in anticipation for your help:
// The pin configuration for the shift register.
int data = 2;
int clock = 3;
int latch = 4;
// the animation sequence for the LED display
// first column is the LED status in binary form, second column is the timing in milliseconds
byte patterns[48] = {
B00000001, 100,
B00000010, 100,
B00000100, 100,
B00001000, 100,
B00010000, 100,
B00100000, 100,
B01000000, 100,
B10000000, 100,
B01000000, 100,
B00100000, 100,
B00010000, 100,
B00001000, 100,
B00000100, 100,
B00000010, 100,
B00000001, 100,
B00011000, 200,
B00100100, 200,
B01000010, 200,
B10000001, 200,
B01000010, 200,
B10100101, 200,
B01011010, 200,
B00100100, 200,
B00011000, 200
};
// variables used for status
int pattern_index = 0;
int pattern_count = sizeof(patterns) / 2;
void setup() {
// setup the serial output if needed
Serial.begin(9600);
// define the pin modes
pinMode( data, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(latch, OUTPUT);
}
void loop() {
// activate the patterns
digitalWrite(latch, LOW);
shiftOut(data, clock, MSBFIRST, patterns[pattern_index*2]);
digitalWrite(latch, HIGH);
// delay for the timing
delay(patterns[(pattern_index*2) + 1]);
// move to the next animation step
pattern_index ++;
// if we're at the end of the animation loop, reset and start again
if (pattern_index > pattern_count) pattern_index = 0;
}