74hc595 with 7 segment display only showing half the numbers

I'm using a 74HC595N in order to control a 7 segment display (common cathode), the problem being that the display goes blank every two digits, as in, it displays 1, 3, 5, 7, 9 but not 0, 2, 4, 6, 8 even thougth it should.
Code:

int latch=9;  //STCP 
int clock=10; //SHCP
int data=8;   //DS

int numbers[] = {0b11111100, 0b01100000, 0b11011010, 0b11110010, 0b01100110, 0b10110110, 0b10111110,
0b11100000, 0b11111110, 0b11110110};

void setup() {
  pinMode(latch,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(data,OUTPUT);
}

int i = 0;
void Change()
{
  digitalWrite(latch,LOW);  
  shiftOut(data,clock, LSBFIRST, numbers[i]);  
  digitalWrite(latch,HIGH);
}

void loop() 
{
  for(i = 0; i < 10; i++)
  {
    Change();
    delay(500);
    //Change();
    //delay(1000);
  }     
}

The code

Change();
delay(1000);

is commented out as it works if I add that in, but that would be extra instructions that shouldn't be there. Also, I've tried to simulate the same set up in Proteus and it works just fine.
Schematics (using an ATMEGA328P instead of my physical Arduino UNO):

I've tried changing the display and the 74hc595, but to no avail.
I'm using an external 5V power supply for the display and the shift-register IC.

void Change(int ix)
{
  digitalWrite(latch,LOW);  
  shiftOut(data,clock, LSBFIRST, numbers[ix]);  
  digitalWrite(latch,HIGH);
}

void loop() 
{
  for(int i = 0; i < 10; i++)
  {
    Change(i);
    delay(500);
  }     
}

Saddly, the solution isn't that simple

How much current can the register supply, on each pin and in total?
Try to double the resistor values for less current draw.

try
uint8_t numbers[ ] =

Each pin can supply 35mA (I'm only using about 5mA) and in total, the IC can take 70mA (only using 35mA in my case), so current doesn't seem to be the problem

Didn't work

Does this mean all outputs are low or are disabled?

What if you make i a local variable inside the for loop and pass it as a parameter to Change(i);

The MR input should not float!

1 Like

Can't believe that was what was giving me all this trouble
Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.