Control 8x8 Led Matrix with 2 74HC595

Hey Everyone,

I was wondering if anyone knew of a good resource/tutorial for using a couple of 74HC595 shift registers in order to create an 8x8 LED matrix? I've seen some projects using these, but they never seem to explain it very well. So if you happen to have one bookmarked, let me know please!

Any references you find are probably not going to be good references. They will probably have been written by someone with a poor understanding, or no understanding, of the limitations of the 74hc595, and the circuit may damage the chips. These chips are not a good choice for driving 8x8 led matrix, unless you introduce other components to overcome their limitations.

Try this one Arduino Workshop

It tells you what functions are needed for any scanning matrix.

So the important question here is why you want to use 74HC595s to do this in a tedious and ineffective way when the unquestioned proper way to do it is to use a MAX7219 which is cheaply available as a neat module on eBay?

Should you answer that puzzler, we might just get somewhere. :roll_eyes:

Could be that the OP wants to learn how multiplexing works. Max7219 won't help with that. It just does it all for you.

I have a suggestion for the OP. Use two shift registers, but make one of them a 74hc595 and the other a tpic6b595 (or tpic6c/d595, whichever is cheapest). This will overcome an important one of (but not all of) the 74hc595's limitations. Tpic6b595 is a very similar chip to 74hc595, but can sink far more current, allowing for a brighter display. But it cannot source any current, hence the other chip still needs to be 74hc595.

It's my homework after the class. I have a guidebook but it seems to be very old, I followed the instructions carefully but it didn't work.

Here is the picture and code in that book.

sketch_nov11a.ino (1.52 KB)

Please post the code in code tags, I can't open .ino files on my phone. The forum guide in the sticky post will tell you how.

What value resistors are being used there, I can't read the colour code? In that circuit, they should be around 800 ohms, otherwise the '595 could be damaged by too much current.

Sorry, I'm new in this forum.
The book says this code will display a heart on screen like this.

#include <TimerOne.h> 
int latchPin = 8; // Pin connected to Pin 12 of 74HC595 (Latch) 
int clockPin = 12; // Pin connected to Pin 11 of 74HC595 (Clock)
int dataPin =11; // Pin connected to Pin 14 of 74HC595 (Data)
byte led[8]; // 8 element unsigned integer array to store the sprite
void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);      // open the serial port at 9600 bps:    
  pinMode (latchPin, OUTPUT); // set the 3 digital pins to outputs 
  pinMode (clockPin, OUTPUT);
  pinMode (dataPin, OUTPUT) ;
  led[0] = B11111111; //enter the binary representation of the image into the array
  led[1] = B10000001;
  led[2] = B10111101; 
  led[3] = B10100101;
  led[4] = B10100101;
  led[5] = B10111101;
  led[6] = B10000001;
  led[7] = B11111111;
  Timer1.initialize(10000); // set a timer of length 10000 microseconds (1/ 100th of a second)
  Timer1.attachInterrupt(screenUpdate); // attach the screenUpdate function to the interrupt timer
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int i=0;i <8; i++){
    led[i] = ~led[i]; // invert each row of the binary image
  }
  delay(500);
}

void screenUpdate(){  // function to display image
  byte row = B10000000;
  for(byte k = 0; k< 9; k++){
    digitalWrite(latchPin, LOW);// open latch ready to receive data
    shiftIt(~led[k]); // shift out the LED array (inverted)
    shiftIt(row); // shift out row binary number
    digitalWrite (latchPin,HIGH); // Close the latch, sending the data in the registers out to the matrix
    row = row<<1; // bitshift left
  }
}

void shiftIt(byte dataOut){ //Shift out 8 bits LSB first, on rising edge of clock
  boolean pinState;
  digitalWrite(dataPin, LOW); // clear shift register read for sending data
  for(int i =0; i<8; i++) { // for each bit dataOut send out a bit
    digitalWrite(clockPin, LOW); // set clockPin to LOW prior to sending bit
    if(dataOut & (1<<i)){ // if the value of DataOut and (logical AND) a bitmask are true, set pinState to 1 (HIGH)
      pinState = HIGH;
    }
    else{
      pinState = LOW;
    }
// sets dataPin to HIGH or LOW depending on pinState
    digitalWrite (dataPin, pinState) ;
    digitalWrite(clockPin, HIGH); //send bit out on rising edge of clock
    digitalWrite(dataPin, LOW);
  }
  digitalWrite(clockPin,LOW); // stop shifting
}

i use 8 1k ohm resistors, 2 75hc595 and a 8x8 Led Matrix 1088AB-2

The 1K resistors will protect the 74hc595 from damage, but the display will not be very bright. The LEDs will only glow dimly because they will receive less than half a milliamp on average. But indoors in dim light they should be visible.

The sketch you posted will not display a heart shape. It will display a square inside another sqaure, if it works.

What is the title of this book? I would like to know so I can tell others not to buy it. The code is bad and the circuit is bad.

You said something in post #5 that you should never say: "it didn't work". I don't know if you meant that no LEDs lit at all or that you saw a square pattern instead of a heart pattern. You should always say exactly what happened, and what you expected to happen.

You need two 0.1uF ceramic caps as bypass caps for the two chips. Without them, chips can often misbehave. The caps can be placed across the breaboard power rails, one close to each chip. It not worthwhile checking anything else until you have those in place, because it could be the problem.

PaulRB:
Could be that the OP wants to learn how multiplexing works.

Entirely fair enough and in this case, absolutely correct.

A purely educational exercise, the end game of which is to learn that when the correct hardware is readily (and cheaply) available, that is the proper way to do the job. :grinning: