LED matrix with 74HC959 and 4019 timer

Hey,

I have never really posted, but I've been on arduino for a while. Never needed much help until now.

I made the 24x6 display from : http://www.instructables.com/id/Make-a-24X6-LED-matrix
It works fine. No problemos BUT I want to light up single LED on my matrix. It has 3x74HC595 for the columns and 1x4019 decade counter for the rows.
So, I get that shift register are bits that you push until the registry is full. In my case I have 24 bits to fill. I would need max 111111111111111111111111 which would be 0xFFFFFF, that takes care of the columns. And I would need to sync with the row.
Say I want to light up all first row of the matrix and not the other rows , I would do this “{0xFFFFFF,0x000000, 0x000000, 0x000000, 0x000000, 0x000000}”
I could define this as “A”, then I could have
int A[18] = {B00000000,B00000000,B00000001,B00000000,B00000000,B00000010,B00000000,B00000000,B00000100,B00000000,B00000000,B00001000,B00000000,B00000000,B00010000,B00000000,B00000000,B00100000};

The goal would have as input “A1,C1,A1,B1,C1” displayed with 500ms delay.

I think I am doing something wrong, maybe with the 8-bit..I am lost.

int A[18] = {B00000000,B00000000,B00000001,B00000000,B00000000,B00000010,B00000000,B00000000,B00000100,B00000000,B00000000,B00001000,B00000000,B00000000,B00010000,B00000000,B00000000,B00100000};

byte n[3] = {B00000000,B00000000,B00000001};

int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int j = 6;

void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}

void loop(){
  
//corde1

for(int i=0;i<15;i++){
                   if( j == 6){
            digitalWrite(Reset,HIGH);
            digitalWrite(Reset,LOW);
            j = 0;
          }   
  
  
  shiftOut(dataPin, clockPin, MSBFIRST, A[i]);
    shiftOut(dataPin, clockPin, MSBFIRST, A[i+1]);
      shiftOut(dataPin, clockPin, MSBFIRST, A[i+2]);
  digitalWrite(latchPin, HIGH);
  delay(10);
  digitalWrite(latchPin, LOW);
         
          digitalWrite(clock,HIGH);
          digitalWrite(clock,LOW);
          j++;
delay(500);
}      


  
}

I think the problem is that you are sending most value several times. Try this:

  // Select the first row
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);

  for(int i=0;i<5;i++)  // For each row
    {
    // Send 24 bits to the shift registers
    shiftOut(dataPin, clockPin, MSBFIRST, A[i*3]);
    shiftOut(dataPin, clockPin, MSBFIRST, A[i*3+1]);
    shiftOut(dataPin, clockPin, MSBFIRST, A[i*3+2]);
    digitalWrite(latchPin, HIGH);
    digitalWrite(latchPin, LOW);
    delay(4); // Keep the row lit for a bit.  Increase delay to increase brightness.  Decrease to reduce flicker.

    // Clear the row so we can go on to the next row without smearing
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);
    digitalWrite(latchPin, LOW);

    // On to the next row.
    digitalWrite(clock,HIGH);
    digitalWrite(clock,LOW);
  }      
 }

You will need to follow the "Blink without delay" example to schedule image changes. You might want to make a pointer to the current image so you can change the image easily:

// Global variables
char **images = {A, B, C, A, B, D};
char * image = images[imageIndex];
int imageIndex = 0;

// code in loop() to select an image
if (millis() - lastChangeTime > 500)
    {
    imageIndex++;
    if (imageIndex > 5) imageIndex = 0;
    image = images[imageIndex];
    lastChangeTime = millis();
    }

Then in the code that outputs the data you would use 'image[i*3]' instead of 'A[i*3]', etc.

That actually helped with the smearing !!

// Clear the row so we can go on to the next row without smearing
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);
    digitalWrite(latchPin, LOW);

thanks :grin:

Ok, I actually got the hang of it. I think I'll write up a tutorial when I have free time, because I haven't found a good one.