liudr:
If you attached a second shift register and use 4 of its outputs to drive the NPN transistors you are driving with digital pins, you may save those 4 pins and even go to 8 7-segment displays The shift registers are cheap.
Hi;
Could you pls explain how can I use second shift register?
I have this model:
http://blog.vcc2gnd.com/2014/04/4-digits-led-7-segment-module-with-2x_69.html
and I don't know how to use it.
tanks
I hooked up a four digit 7-segment display to one shift register as was talked about in this thread.
I also took liudr's advice and hooked up the four digit cathode pins (through a 330Ohm resistor) into Q1, Q2, Q3, Q4 of another shift register (shift2), this made it so that I was only using a total of 3 arduino pins to control this whole setup of 4 7-segment displays!
I connected shift2's latch and clock pins to my first shift register (shift1) and connected pin 9 of shift1 which is the data overflow pin into shift2's pin 14 which is the data pin.
Any extra data you send to shift1 then gets transferred to shift2 and can be processed normally.
I created a new class to call to utilize both of the shift registers called shiftyOut():
void shiftyOut(byte whichDigit, byte whichNum) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, whichDigit);
shiftOut(dataPin, clockPin, MSBFIRST, whichNum);
digitalWrite(latchPin, HIGH);
delay(500);
}
So when calling shiftyOut() you send it first the byte that corresponds to which digit you want to turn on. The second byte you send it should tell you which of the 7-segments you are going to turn on in that digit.
"I also took liudr's advice and hooked up the four digit cathode pins (through a 330Ohm resistor) into Q1, Q2, Q3, Q4 of another shift register (shift2), "
What kind of shift register? You could be asking the 2nd shift register to source/sink 70mA.