Hi everyone
I'm currently trying to use the SN74HC595 shift register to interface it with a 7 segment 4 digit display. I'm trying to cycle through each digit with a number corresponding to the digit. The problem is for some reason my code only works for number 1 and 4, while most number simply doesn't work or flicker a little bit. I noticed that the number 1 and 4 in my circuit and code starts with a 0 bit (eg. 1 is B01100000) and numbers that doesn't work starts with a 1 bit (eg. 2 is B11011010). If I change the first bit to 0 (eg. change 2 to B01011010), the number displays properly except for the top (A) segment. I'm using the circuit given by this website: http://osoyoo.com/wp-content/uploads/2017/08/4dss-74hc595-fritzing.jpg , but I'm using a different code. Here is my code:
int clk = 6;
int latch = 5;
int data = 4;
int CAS[4] = {12, 11, 10, 9};
byte numbers[10] {B11111100, B01100000, B11011010, B11110010, B01100110, B10110110, B10111110, B11100000, B11111110, B11110110};
void setup() {
pinMode(CAS[0], OUTPUT);
pinMode(CAS[1], OUTPUT);
pinMode(CAS[2], OUTPUT);
pinMode(CAS[3], OUTPUT);
pinMode(clk, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(data, OUTPUT);
digitalWrite(CAS[0], HIGH);
digitalWrite(CAS[1], HIGH);
digitalWrite(CAS[2], HIGH);
digitalWrite(CAS[3], HIGH);
}
void loop(){
for (int i=0; i<4; i++)
{
digitalWrite(latch, LOW);
shiftOut(data, clk, LSBFIRST, numbers[i+1]);
digitalWrite(latch, HIGH);
digitalWrite(CAS[i], LOW);
delay(1000);
digitalWrite(CAS[i], HIGH);
}
}
I've checked all other numbers, and since all of them (except 1 and 4) starts with a 1 bit, none of them works, unless I change the first bit to 0.
Any help would be greatly appreciated
Thanks