How does LED matrix circuit work in the following example?

The circuit below shows how to build an LED matrix with shift register multiplexing.

From what I understand, R1-R8 is the column vector setting the LEDs high or low and the shift register will pick one row at a time.

What is the output of the shift register Q0-Q7?

In order to light up bottom left LED, I Would need to set R1 3.3V and Q0 grounded (or 0V I guess?) whilst Q1 - Q7 must be floating. However, in this circuit, I don't see how to float the Q1-Q7.

Or are Q1-Q7 actually 3.3V so that all other LED in the first row have zero potential with the Q1-Q7? In the example below, it's more understandable as the shift register is switching the transistors, therefore, multiplexing the rows to the ground.

A - How does the first circuit work?

B - What are advantages and disadvantages of the first and the second circuit? • The second circuit is an array of lamps, and the diodes will prevent the MOSFETs from working properly. – Ignacio Vazquez-Abrams Nov 22 '17 at 6:12

... whilst Q1 - Q7 must be floating.

No they don't. They simply must not provide a voltage that will light the LEDs to any real extent. Pulling them low, and therefore the anodes to 0V, suffices.

• How would it work in the example above if I want to light up bottom left LED? R {3v, 0, 0, .., 0} and Q {0v, 3v, 3v, ..., 3v}? – Arturs Vancans Nov 22 '17 at 6:00
• The anode of a LED must be more positive than the cathode if you want to light it up in normal use. – Ignacio Vazquez-Abrams Nov 22 '17 at 6:02

If you examine the first circuit closely you can see that to turn on an LED you need a low from the Arduino GPOI line and a high from a single output of the shift register.

So to light the bottom left LED you would output a 0 (low on pin(13) and a 1 (high) on Q0, all the other Qx outputs would be 0(low).

Effectively the shift register allows you to select a single column from the 8 in the display, and the Arduino pin(x) selects an individual LED in the selected column.

The second circuit you show is incomplete, but operates in the same manner, this time using a FET to sink the current for an LED to ground.

• What is the advantage of sinking the LED to the ground versus going through the GPIO? – Arturs Vancans Nov 22 '17 at 6:50

The data sheet for the SN74HC494N shows the part's timing diagram. Basically the Q0 - Q7 outputs are a "marching one" sequence:

0      7 clk
10000000  0
01000000  1
00100000  2
...

So with Q0 logic HIGH, you would need to program pin 13 on the Arduino as logic LOW in order to turn on the LED that's located on the bottom left corner of the matrix:

+5V ->
-> 74HC595N VCC
74HC595N Q0(HIGH) ->
-> LED Anode
LED Cathode ->
-> 220 ohm resistor R1 ->
-> Arduino pin 13 (LOW)
Arduino GND ->
-> GROUND

In this type of circuit you need to think of the shift register as a power-router.

What you really have is a number of circuits hooked up in parallel.

Lets redraw it a bit to make it clearer. simulate this circuit – Schematic created using CircuitLab

Perhaps you can see in the above that the two parallel circuits are driven by two common data lines at the bottom. Now, obviously, which set of LEDs light up will depend on which circuit it powered.

However, in this instance "powered" actually means. "At a voltage greater than the Low level signal level applied to the data lines PLUS the diode voltage drop."

As such, the HC595 outputs, when high, provide that power to the appropriate circuit. When the outputs are low, the voltage level is too low to turn on the LEDs in that circuit.

This type of circuit is used to multiplex many LEDS into a few IO lines from whatever is driving it. Each row or column will only be on for 1/(row or column count) of the time. As such, you lose some brightness from the LEDs.