Use two buttons to control 3 595 shift registers

I’m, still a novice, working on a LED clock, which will have 12 output LED’s, for the hour hand, and 12 output LED’s for the minutes hand (set at 5 minute intervals). I have the hardware working, and most of the sketch finished including the main “time keeping” routine. I have added two buttons, and have successfully been able to drive the shift register, be it chaotically, and have not been able to incorporate the button shift changes into the main time keeping routine. The routine continues where it left off after the button press and expired delay time loops it. Please help me with the time setting in the “void stateChange()” portion of this code .

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
int pbIn = 0;                  // Interrupt 0 is on DIGITAL PIN 2!
volatile int state = LOW;      // The input state toggle
//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataGREEN;
byte dataRGB;
byte dataArrayRED[144]; //the number in the [ ] is the amount of array lines
byte dataArrayGREEN[144]; //the number in the [ ] is the amount of array lines
byte dataArrayRGB[144];
void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  Serial.begin(9600);
//Attach the interrupt to the input pin and monitor for ANY Change 

attachInterrupt(pbIn, stateChange, CHANGE);
  //Arduino doesn't seem to have a way to write binary straight into the code 
  //so these values are in HEX.  Decimal would have been fine, too. 
 //chip#1          The LED's are RED or GREEN, just named them dataArrayRGB because its  short
  dataArrayRGB[0] = 0x11; // begin hour 1, minute 5
  dataArrayRGB[1] = 0x21; // 10m
  dataArrayRGB[2] = 0x41; // 15m
  dataArrayRGB[3] = 0x81; // 20m
  dataArrayRGB[4] = 0x01;
  dataArrayRGB[5] = 0x01;
  dataArrayRGB[6] = 0x01;
  dataArrayRGB[7] = 0x01;
  dataArrayRGB[8] = 0x01;
  dataArrayRGB[9] = 0x01;
  dataArrayRGB[10] = 0x01;
  dataArrayRGB[11] = 0x01; // 1h finish
 // it continues up to dataArrayRGB[144]  but had to cut this due to restrictions on post size on this site
  
  // chip#3
  dataArrayRED[0] = 0x0; // begin 1h
  dataArrayRED[1] = 0x0;
  dataArrayRED[2] = 0x0;
  dataArrayRED[3] = 0x0;
  dataArrayRED[4] = 0x10; // 25
  dataArrayRED[5] = 0x20; // 30
  dataArrayRED[6] = 0x40; // 35
  dataArrayRED[7] = 0x80; // 40
  dataArrayRED[8] = 0x0;
  dataArrayRED[9] = 0x0;
  dataArrayRED[10] = 0x0;
  dataArrayRED[11] = 0x0;
// it continues up to dataArrayRED[144]  but had to cut this due to restrictions on post size on this site
  
  //Arduino doesn't seem to have a way to write binary straight into the code 
  //so these values are in HEX.  Decimal would have been fine, too. 
  
  dataArrayGREEN[0] = 0x0; // begin 1h
  dataArrayGREEN[1] = 0x0;
  dataArrayGREEN[2] = 0x0;
  dataArrayGREEN[3] = 0x0;
  dataArrayGREEN[4] = 0x0;
  dataArrayGREEN[5] = 0x0;
  dataArrayGREEN[6] = 0x0;
  dataArrayGREEN[7] = 0x0;
  dataArrayGREEN[8] = 0x10; // 45
  dataArrayGREEN[9] = 0x20; // 50
  dataArrayGREEN[10] = 0x40; // 55
  dataArrayGREEN[11] = 0x80; // 60
  // it continues up to dataArrayGREEN[144]  but had to cut this due to restrictions on post size on this site
  
  //function that blinks all the LEDs
  //gets passed the number of blinks and the pause time
  blinkAll_2Bytes(2,500); 
}

void loop() {


  for (int j = 0; j < 144; j++) { // in for (int j = 0; j < X; j++) {
    //the X is the amount of one run before the array loops again.
    //load the light sequence you want from array
    dataRED = dataArrayRED[j];
    dataGREEN = dataArrayGREEN[j];
    dataRGB = dataArrayRGB[j];
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(1300);
  }
}
 // Below lies the problem code:
void stateChange()
{
state = !state;
int j;
 dataGREEN = dataArrayGREEN[j++];
 dataRED = dataArrayRED[j++];
 dataRGB = dataArrayRGB[j++];
 
digitalWrite(latchPin, LOW);
 
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, HIGH);  
}

// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first, 
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut?
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights. 
  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result 
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000 
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else {	
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin  
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }

  //stop shifting
  digitalWrite(myClockPin, 0);
}


//blinks the whole register based on the number of times you want to 
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll_2Bytes(int n, int d) {
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(200);
  for (int x = 0; x < n; x++) {
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 255);
    digitalWrite(latchPin, 1);
    delay(d);
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(d);
  }
}

judasknox: //Arduino doesn't seem to have a way to write binary straight into the code //so these values are in HEX. Decimal would have been fine, too.

can't we write binary numbers with the B prefix (at least 8bit numbers)? Something like B10001 would be your 0x11 or decimal 17?

as to your code, what is the actual problem? What isn't working? What would you like to happen when you press your buttons?

First off you are wasting a lot of code defining those arrays you should define the initial contents of an array when you declare them like this (taken from some of my code but you get the idea) :-

byte ledBuffer[] = {
    // row 1 (botom)
   //     lower LEDs not used        bb    bg    gg    rr    rb    bb    gg    gr    rr    bb    bg    gg     rr    rb    bb      gg    gr    rr
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x04, 0x00, 0x80, 0x40, 0x00, 0x40, 0x08, 0x04, 0x00, 0x04, 0x00, 0x80,  0x40, 0x00, 0x40,   0x08, 0x04, 0x00,  // "white" row
    // row 2
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,  0x40, 0x00, 0x00,   0x00, 0x04, 0x00, // red row
        // row 3
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00,  0x00, 0x00, 0x00,   0x20, 0x00, 0x00, // green row
        // row 4 (top)
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,  0x00, 0x00, 0x20,   0x00, 0x00, 0x00  // blue row
};

Next why are you using interrupts?

Have you got a capacitor on the latch pin like in the tutorials? If so remove it immediately and connect it to the 5V. If you have no capacitors at all fit 0.1 uF ceramic capacitors across the supply pins of all chips.

Finally have you considered the denouncing of your input push buttons?

boguz:

judasknox: //Arduino doesn't seem to have a way to write binary straight into the code //so these values are in HEX. Decimal would have been fine, too.

can't we write binary numbers with the B prefix (at least 8bit numbers)? Something like B10001 would be your 0x11 or decimal 17? as to your code, what is the actual problem? What isn't working? What would you like to happen when you press your buttons?

When I press button 1, I want the "5 minute" LED to advance to the next LED, which would be equal to 10 minutes after and so on, one LED at a time for setting the "minutes" time, then for button 2 , advance what would be an hour to set the "hour" time. So far when I press the button 1, for example, I can get a LED to light up but only temporarily, then it switches back to the main sequence without holding the change. "can't we write binary numbers with the B prefix (at least 8bit numbers)? Something like B10001 would be your 0x11 or decimal 17?" I'm sorry about the" Arduino doesn't seem to have a way to write binary ...", that statement was in the shift register example code I copied. I left the authors name in the title statement on my original code but deleted when I was pasting the code into this forum along with a lot of the defined arrays to be able to comply with the limit on size here on the forum. thanks for looking,

boguz:

judasknox: //Arduino doesn't seem to have a way to write binary straight into the code //so these values are in HEX. Decimal would have been fine, too.

can't we write binary numbers with the B prefix (at least 8bit numbers)? Something like B10001 would be your 0x11 or decimal 17?

Or you could use the supported c style of writing binary numbers (works for all supported bit sizes) with the 0b prefix. Your 0x11 example becomes 0b10001.

Grumpy_Mike: First off you are wasting a lot of code defining those arrays you should define the initial contents of an array when you declare them like this (taken from some of my code but you get the idea) :-

byte ledBuffer[] = {
    // row 1 (botom)
   //     lower LEDs not used        bb    bg    gg    rr    rb    bb    gg    gr    rr    bb    bg    gg     rr    rb    bb      gg    gr    rr
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x04, 0x00, 0x80, 0x40, 0x00, 0x40, 0x08, 0x04, 0x00, 0x04, 0x00, 0x80,  0x40, 0x00, 0x40,   0x08, 0x04, 0x00,  // "white" row
    // row 2
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,  0x40, 0x00, 0x00,   0x00, 0x04, 0x00, // red row
        // row 3
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00,  0x00, 0x00, 0x00,   0x20, 0x00, 0x00, // green row
        // row 4 (top)
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,  0x00, 0x00, 0x20,   0x00, 0x00, 0x00  // blue row
};

Next why are you using interrupts?

Have you got a capacitor on the latch pin like in the tutorials? If so remove it immediately and connect it to the 5V. If you have no capacitors at all fit 0.1 uF ceramic capacitors across the supply pins of all chips.

Finally have you considered the denouncing of your input push buttons?

Thanks I'll mess with that code while I wait for the button "time set" help. I can kick myself for missing that... the code I used with my Chinese 8x8 array LED uses that same kind of layout. I was using example code I found online, in my original post, that had a similar form to what I am trying to accomplish and it had a bunch of arrays (12) so I used and expanded it without much thought. I couldn't fit the 144 lines per three 595 chips on this forum. Your help will shorten that significantly. Interrupts , for changing the minutes and hours by advancing the designated LED's to set time while the clock is running. I have read that Arduino's, by themselves, will not keep accurate time. The clock will be more of an ornament, using old CD's with holes drilled in them for the LED's, but I want it to have some functionality as a time peice. No capacitors, all I have so far are the resistors to ground for the switches and LED's. I will heed your warning, I'm sure I have some 0.1uF caps laying around. I have come across the concept of debouncing and some examples of the code, but I have to be able to set the time, on the clock, before I start working on that.

Grumpy_Mike:
First off you are wasting a lot of code defining those arrays you should define the initial contents of an array when you declare them like this (taken from some of my code but you get the idea) :-

byte ledBuffer[] = {
// row 1 (botom)

//     lower LEDs not used        bb    bg    gg    rr    rb    bb    gg    gr    rr    bb    bg    gg     rr    rb    bb      gg    gr    rr
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x04, 0x00, 0x80, 0x40, 0x00, 0x40, 0x08, 0x04, 0x00, 0x04, 0x00, 0x80,  0x40, 0x00, 0x40,   0x08, 0x04, 0x00,  // “white” row
// row 2
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,  0x40, 0x00, 0x00,   0x00, 0x04, 0x00, // red row
        // row 3
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00,  0x00, 0x00, 0x00,   0x20, 0x00, 0x00, // green row
        // row 4 (top)
    0x0, 0x0, 0x0, 0x0, 0x0, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,  0x00, 0x00, 0x20,   0x00, 0x00, 0x00  // blue row
};

Well I tried modifying the code as you suggested, with what you showed me and the code I had for my 8x8 LED array, with very little success! If I could see more of your code it would help greatly, so I can get back to the original objective which is to have a ornamental semi-accurate clock. Do you suggest I not use interrupt pins for the buttons? I read somewhere that debouncing can not be done with the interrupt pins, but that isn’t a priority for this project. Please be patient, if its way off, I’m an old newbie. Anyhow, this it what I came up with:

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
unsigned char i;
unsigned char j; 
//int pbIn = 0;                  // Interrupt 0 is on DIGITAL PIN 2!
//volatile int state = LOW;      // The input state toggle
//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataGREEN;
byte dataRGB;
//byte dataArrayRED[144]; //the number in the [ ] is the amount of array lines
//byte dataArrayGREEN[144]; //the number in the [ ] is the amount of array lines
//byte dataArrayRGB[144];
unsigned char disp1[16][3]={
  
{0x11,0x00,0x00},
{0x21,0x00,0x00},
{0x41,0x00,0x00},
{0x81,0x00,0x00},
{0x01,0x10,0x00},
{0x01,0x20,0x00},
{0x01,0x40,0x00},
{0x01,0x80,0x00},
{0x01,0x00,0x10},
{0x01,0x00,0x20},
{0x01,0x00,0x40},
{0x01,0x00,0x80},
{0x0,0x10},
{0x0,0x20},
{0x0,0x40},
{0x0,0x80},
};

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  Serial.begin(9600);
//Attach the interrupt to the input pin and monitor for ANY Change 

//attachInterrupt(pbIn, stateChange, CHANGE);
  
  //function that blinks all the LEDs
  //gets passed the number of blinks and the pause time
  blinkAll_2Bytes(2,500); 
}
void loop()
{ 
   for(j=0;j<24;j++) // the number for "X" as in "(for(j=0;j<X;j++))" IS THE AMOUNT OF COMMAND LED DISPLAY LINES echoed
  {  
   for(i=1;i<8;i++)
 
    dataRGB = (i,disp1[j][i-1]);
   // for(i=8;i<16;i++)
    //dataGREEN = (i,disp1[j][i-1]);
   // for(i=16;i<24;i++)
   // dataRED = (i,disp1[j][i++]);
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(1000);
  }
  { 
   for(j=0;j<24;j++) // the number for "X" as in "(for(j=0;j<X;j++))" IS THE AMOUNT OF COMMAND LED DISPLAY LINES echoed
  {  
   for(i=8;i<15;i++)
 
    dataRED = (i,disp1[j][i-1]);
   // for(i=8;i<16;i++)
    //dataGREEN = (i,disp1[j][i-1]);
   // for(i=16;i<24;i++)
   // dataRED = (i,disp1[j][i++]);
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(1000);
  }
   { 
   for(j=0;j<24;j++) // the number for "X" as in "(for(j=0;j<X;j++))" IS THE AMOUNT OF COMMAND LED DISPLAY LINES echoed
  {  
   for(i=16;i<23;i++)
 
    dataGREEN = (i,disp1[j][i-1]);
   // for(i=8;i<16;i++)
    //dataGREEN = (i,disp1[j][i-1]);
   // for(i=16;i<24;i++)
   // dataRED = (i,disp1[j][i++]);
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(1000);
  }
}}}
 /* 
void stateChange()
{

state = !state;
int j;
 dataGREEN = dataArrayGREEN[j++];
 dataRED = dataArrayRED[j++];
 dataRGB = dataArrayRGB[j++];
 
digitalWrite(latchPin, LOW);
 
    //move 'em out
    shiftOut(dataPin, clockPin, dataGREEN);   
    shiftOut(dataPin, clockPin, dataRED);
    shiftOut(dataPin, clockPin, dataRGB);
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, HIGH);  
}
*/
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first, 
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut?
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights. 
  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result 
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000 
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else {	
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin  
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }

  //stop shifting
  digitalWrite(myClockPin, 0);
}


//blinks the whole register based on the number of times you want to 
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll_2Bytes(int n, int d) {
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(200);
  for (int x = 0; x < n; x++) {
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 255);
    digitalWrite(latchPin, 1);
    delay(d);
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(d);
  }
}

with very little success!

You have to be a bit more specific that this.

What is this line supposed to be doing?

dataRGB = (i,disp1[j][i-1]);

yes it compiles but what do you think the value will be? I have no idea of what it does.

There is too much going on here try and cut it down and build it up step by step.

Since I didn't know how to write the code, from scratch, I borrowed that bit of code from the 8x8 LED matrix code, in hope that it would be at least close to what the former code did. It didn't and I'm stuck , and was hoping someone would be able to fix it or point me in the right direction on how to fix the code.

Yes but the code you took never had that line in it did it?

You have to build up things step by step. What are you trying to do with that piece of code? You should not write great lumps of code without testing them. Break what you want to do down into functions and attack one function at a time. But you have to have it straight in your own mind what each part of the code is supposed to be doing. Only when you know this can you worry about how to get the code to do that function.

You can only write code if you know what the hardware is and you haven't posted any schematics.

The only difference between mine and the schematics and breadboard view, in the link below, is that I used three 595 chips instead of two. This is also where I obtained and modified the original code, for three chips, I used originaly. The code is on the “Code Sample 2.3 - Dual Defined Arrays” page towards the bottom and the schematic pis are on the original link

The only difference between mine and the schematics and breadboard view, in the link below, is that I used three 595 chips instead of two.

There are many way to cock up adding an extra shift register. If you are not willing to post a schematic of what you actually have it is hard to help.

What is going on. First you said you had an 8 by 8 array and now you are saying you just have 24 LEDs connected to three shift registers? It is all of you circuit that is needed.

That schematic is wrong, the capacitor should go to the 5V supply and not the latch pin. There needs to be one on each chip.

Sorry but I can't see the relationship between that code and what you posted.

To further clarify I made a small video with my Iphone, sorry about the quality; of my breadboard running my original code from my original post. The code may be huge, but it works. I knew there had to be a better way to execute the mechanics of what I wanted to achieve, and when you posted your sample code I was happy to try to revamp my code merging my original code in post 1, and the following code that I have from another project that is an 8x8 matrix that uses shift registers. Unfortunately I could not successfully merge the code. The link to the video: http://youtu.be/vFgSpSPuyTk

The 8x8 LED matrix code I tried to merge with:

 unsigned char i;
 unsigned char j; 
/*port definition*/
int Max7219_pinCLK = 10;
int Max7219_pinCS = 9;
int Max7219_pinDIN = 8;

unsigned char disp1[64][8]={ // 64 being the number of lines,
                             // with up to 8 characters per line.

{0x01},
{0x02},
{0x04},
{0x08},
{0x10},
{0x20},
{0x40},
{0x80},
{0x0,0x01},
{0x0,0x02},
{0x0,0x04},
{0x0,0x08},
{0x0,0x10},
{0x0,0x20},
{0x0,0x40},
{0x0,0x80},
{0x0,0x0,0x01},
{0x0,0x0,0x02},
{0x0,0x0,0x04},
{0x0,0x0,0x08},
{0x0,0x0,0x10},
{0x0,0x0,0x20},
{0x0,0x0,0x40},
{0x0,0x0,0x80},
{0x0,0x0,0x0,0x01},
{0x0,0x0,0x0,0x02},
{0x0,0x0,0x0,0x04},
{0x0,0x0,0x0,0x08},
{0x0,0x0,0x0,0x10},
{0x0,0x0,0x0,0x20},
{0x0,0x0,0x0,0x40},
{0x0,0x0,0x0,0x80},
{0x0,0x0,0x0,0x0,0x01},
{0x0,0x0,0x0,0x0,0x02},
{0x0,0x0,0x0,0x0,0x04},
{0x0,0x0,0x0,0x0,0x08},
{0x0,0x0,0x0,0x0,0x10},
{0x0,0x0,0x0,0x0,0x20},
{0x0,0x0,0x0,0x0,0x40},
{0x0,0x0,0x0,0x0,0x80},
{0x0,0x0,0x0,0x0,0x0,0x01},
{0x0,0x0,0x0,0x0,0x0,0x02},
{0x0,0x0,0x0,0x0,0x0,0x04},
{0x0,0x0,0x0,0x0,0x0,0x08},
{0x0,0x0,0x0,0x0,0x0,0x10},
{0x0,0x0,0x0,0x0,0x0,0x20},
{0x0,0x0,0x0,0x0,0x0,0x40},
{0x0,0x0,0x0,0x0,0x0,0x80},
{0x0,0x0,0x0,0x0,0x0,0x0,0x01},
{0x0,0x0,0x0,0x0,0x0,0x0,0x02},
{0x0,0x0,0x0,0x0,0x0,0x0,0x04},
{0x0,0x0,0x0,0x0,0x0,0x0,0x08},
{0x0,0x0,0x0,0x0,0x0,0x0,0x10},
{0x0,0x0,0x0,0x0,0x0,0x0,0x20},
{0x0,0x0,0x0,0x0,0x0,0x0,0x40},
{0x0,0x0,0x0,0x0,0x0,0x0,0x80},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x01},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x02},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x04},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x08},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40},
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80},

};



void Write_Max7219_byte(unsigned char DATA) 
{   
            unsigned char i;
	    digitalWrite(Max7219_pinCS,LOW);		
	    for(i=8;i>=1;i--)
          {		  
             digitalWrite(Max7219_pinCLK,LOW);
             digitalWrite(Max7219_pinDIN,DATA&0x80);//Obtain the MSB of the data
             DATA = DATA<<1;
             digitalWrite(Max7219_pinCLK,HIGH);
           }                                 
}


void Write_Max7219(unsigned char address,unsigned char dat)
{
        digitalWrite(Max7219_pinCS,LOW);
        Write_Max7219_byte(address);           //
        Write_Max7219_byte(dat);               //
        digitalWrite(Max7219_pinCS,HIGH);
}

void Init_MAX7219(void)
{
 Write_Max7219(0x09, 0x00);       //decode: BCD
 Write_Max7219(0x0a, 0x03);       //Brightness
 Write_Max7219(0x0b, 0x07);       //
 Write_Max7219(0x0c, 0x01);       //
 Write_Max7219(0x0f, 0x00);       //
}



void setup()
{
  
  pinMode(Max7219_pinCLK,OUTPUT);
  pinMode(Max7219_pinCS,OUTPUT);
  pinMode(Max7219_pinDIN,OUTPUT);
  delay(50);
  Init_MAX7219();
}


void loop()
{ 
   for(j=0;j<64;j++) // the (64) is the amount of actual leds it 
                     // counts up to before retuning to the begining.
  {
   for(i=1;i<9;i++)
    Write_Max7219(i,disp1[j][i-1]);
   delay(200);
  } 		
}

WTF now you have code with a Max7219 in it. This is the first time that this chip has made an appearance! Why are you holding out on giving vital information.

Grumpy_Mike: If you are not willing to post a schematic of what you actually have it is hard impossible to help.

I'm sorry it that it seems confusing. I used snippets of the MAX 7219 code and merged it with my original code to try to recreate working code , as your example code implied. My merged code, does not work properly. I posted that MAX 7219 code so you can see where I got the portion of code: (i,disp1[j][i-1]); from; as you asked in an earlier post. I will add the 3rd 595 chip and two buttons to the schematic, above, and try to post it tomorrow. Don't get home from work 'till the a.m.

The line was:-

Write_Max7219(i,disp1[j][i-1]);

That means there is a function called Write_Max7219 and it take in two parameters which are given in brackets. You used what is in those brackets to try and make it equal to some variable. This is just very silly and is like trying to put an answer phone message into a cup of coffee.

The Max7219 is a totally different chip and anything you can do with it has absolutely nothing to do with anything you can do with a shift register so merging the code makes no sense at all. You need to start with a schematic of what you have. Throw all your code away and start from fresh.

and try to post it tomorrow. Don't get home from work 'till the a.m.

Those concepts have little meaning in a world wide forum, as you haven't filled in your location in your detailed page I haven't even a clue of your time zone.

Just got in....EST. Thought that would be the outcome. Thanks for the effort, but the original code was as good as I could do with my limited training. I will settle for an off time device, and bother you no further.

I will settle for an off time device

OK your choice. But if you post the schematic of what you have maybe we could work something out.

In the mean time have you seen my page on multiplexing a matrix? http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

I read through about 3/4 of your tutorial; well written. I will finish reading it later…
So I recreated what I have on my breadboard in the Fritzing program, which is new to me. I noticed I have the wrong Mini Pro. The one in the breadboard layout is the 3.3v version, I’m using the 5v version. The pin layout looks identical between the two Mini Pro’s. Routing turned out to be a bit much for me, I arranged things best I could and used Autoroute, so I’m including the Fritzing breadboard layout pic.