2

I have created my first LED project with a hand made 4X4 LED matrix. The cathodes are joined horizontally to make the rows and the anodes are joined vertically to make the columns the columns. It is controlled by a shift register with the cathodes (rows) connected to pins 0-3 and the anodes (columns) connected to pins 4-7 of the register controlled from an Arduino Nano.

It all works but I have hit upon a limitation that I have not seen in the various videos and tutorials about making LED matrices so I suspect I am missing something.

This code will light up the bottom left LED which I will call position (0,0).

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00011110 );
digitalWrite(latchPin, HIGH);

This code will light up the LED at position (1,1), so one up and one to the right.

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00101101 );
digitalWrite(latchPin, HIGH);

If I then combine the two as below:

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00111100 );
digitalWrite(latchPin, HIGH);

it of course lights up 4 LEDs: (0,0),(0,1),(1,0) and (1,1).

This feels like a limitation of wiring the LEDs in this way because once you power a row in a given column, you cannot unpower it in subsequent columns or vice versa. i.e. lighting (X,Y) and (A,B) means that you cannot have (X,B) and (A,Y) unlit.

However, in the videos I have seen that accompany tutorials on how to make similarly constructed matrices, I can see them lighting up in ways I can't replicate.

How can I light up an LED at positions (0,0) and (1,1) without also lighting up (0,1) and (1,0)?

Is this possible with this configuration?

3
  • 1
    You are looking for "switching between 0,0 and 1,1 fast enough, that eye can't see it's not lit at the same time, but slow enough it's visible" - Multipexing
    – KIIV
    May 1, 2020 at 11:47
  • You need in principle at least 50 Hz to trick your eyes (or actually brains). May 1, 2020 at 11:59
  • @KIIV Thanks that seems to work well. May 1, 2020 at 12:13

1 Answer 1

5

Thanks to KIIV in the comments I figured it out. Apparently the trick is to rapidly switch between columns or rows without ever having two on at the same time.

With the below code running in the main loop it appears that (0,0) and (1,1) are lit at the same time even though they are actually switching rapidly.

void loop() 
{  
  digitalWrite(latchPin, LOW);  
  shiftOut(dataPin, clockPin, MSBFIRST, B00011110 );
  digitalWrite(latchPin, HIGH);
  digitalWrite(latchPin, LOW);  
  shiftOut(dataPin, clockPin, MSBFIRST, B00101101 );
  digitalWrite(latchPin, HIGH);
}
1
  • Yup. That is a common issue with matrixed displays. Note that it's possible to light your LEDs one row or one column at a time. You shift in the states of all the LEDs in 1 row, then turn those off and turn on the LEDs in the next row, etc.
    – Duncan C
    May 1, 2020 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.