74hc595 / MAX7219 display

Hi all,

I seem to be missing something with my 74hc595's, I have a common anode display which I have the 4 segments connected via 4 transistors to the first 74hc595, this seems to work!

The segments are connected to the second 74hc595, as far as I can see these are connected together as they should be.

The problem is I can select displays (I also have 3 LED's connected to the spare 3 lines on the first one, which also works. But I cant change the segments Iluminated! I thought setting the 595 to B00000000 would turn on all segments and B11111111 would turn them off but there is no change?

Does anybody have any suggestions?

I am using 2n3904 transistors with 100R resistors and 1k on the base connected to D0-D4 on the first 595 (which is wired to the Arduino).

my test code is :-

void loop() {

//set latchPin low to allow data flow digitalWrite(latchPin, LOW); shiftOut(B00001111); shiftOut(B10010010) ; // digit select 2=green;4=red; 8=yellow ;16=dig4 ;32 =dig3 ;64 = dig2 128 =dig1

//set latchPin to high to lock and send data digitalWrite(latchPin, HIGH); delay(1000); digitalWrite(latchPin, LOW); shiftOut(B00001111); shiftOut(B01100100) ; // digit select 2=green;4=red; 8=yellow ;16=dig4 ;32 =dig3 ;64 = dig2 128 =dig1

//set latchPin to high to lock and send data digitalWrite(latchPin, HIGH); delay(1000);

}

which is alternating between the outer 2 and inner 2 digits, but all segments are constantly lit!

Thanks for any pointers

Can you post a schematic, I can't follow your description, or at least can't see it would work.

By the way where does the MAX7219 controller chip of the title come in?

Ok, I found one problem I had 2 pins the wrong way, that solved I now have the problem that only one of the 2 bytes is staying in the registers, the driving is working fine now, just both chips are receiving the same data!

(BTW the MAX7219 I was trying to get to work, and couldn’t with the common anode)

so with the code below sending B11100000 turns off ABC which is correct but it is also controling segments 1 2 3?

//Pin connected to Pin 12 of 74HC595 (Latch)
int latchPin = 8;
//Pin connected to Pin 11 of 74HC595 (Clock)
int clockPin = 12;
//Pin connected to Pin 14 of 74HC595 (Data)
int dataPin = 11;

void setup() {
//set pins to output
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);

}

void loop() {
//set latchPin low to allow data flow
digitalWrite(latchPin, LOW);
shiftOut(B11111111) ; // digit select 2=green;4=red; 8=yellow ;16=dig4 ;32 =dig3 ;64 = dig2 128 =dig1
shiftOut(B11100000);
//set latchPin to high to lock and send data
digitalWrite(latchPin, HIGH);
delay(100) ;
}

void shiftOut(int dataOut) {
// Shift out 8 bits LSB first,
// on rising edge of clock

boolean pinState;

//clear shift register read for sending data
digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW);

for(int x=0; x<2; x++) {
// for each bit in dataOut send out a bit
for (int i=0; i<=7; i++) {
//set clockPin to LOW prior to sending bit
digitalWrite(clockPin, LOW);

// if the value of DataOut and (logical AND) a bitmask
// are true, set pinState to 1 (HIGH)
if ( dataOut & (1<<i) ) {
pinState = HIGH;
}
else {
pinState = LOW;
}

//sets dataPin to HIGH or LOW depending on pinState
digitalWrite(dataPin, pinState);
//send bit out on rising edge of clock
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, LOW);
}
}
//stop shifting

digitalWrite(clockPin, LOW);
}

I will ask again:- Can you post a schematic, It does sound like you still have a wiring problem.

When posting code use the # button in the reply box.

that only one of the 2 bytes is staying in the registers,

That will happen if you have not cascaded the two shift registers correctly.

ok, i checked all wiring it seemed to be a coding problem, I adjusted the routine to send 16 bits rather than sending 2 individual sets of 8 bits which seems to work.

I'm not too clued up on C but have extensive BASIC/Assembler experience so its helping me through it!

Now thats working, would it be better to put resistors on each segment rather than on each anode, as 1 and 8 have different brightnesses, due to the different currents needed!

would it be better to put resistors on each segment rather than on each anode,

yes.