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.