1

I am trying to get my 4 digit display (SH5461AS) count from 0 to 9 based on millis() function.

The problem is that it keeps blinking. Even if I display just one number, it shows then it goes black then it shows again, instead of staying on.. Also the upper segment (A) is somewhat delayed. Sometimes it shows, sometimes it does not. I am really not sure what is going on. It is best illustrated in the video: https://youtube.com/shorts/gmbNnvEYq2I

I have arduino UNO R3 hooked up to the 74HC595 8-bit register and from there to the corresponding 'data' pins on the display. It is a common cathode type so I have all of those connected via resistor to the ground.

enter image description here

I appologize for the messy cabeling:

From the display basically all resistors go to ground and all data cables to the register (Q0-DP omitted, segment A-Q7, B-Q6, .., G-Q1 [decimal number 1=A, 2=B, 3=AB,..]).

In the register I got VCC, Ground, data cables, EO grounded, serial data->arduino D4, storage clock -> D5, shift clock -> D6

 #include <LiquidCrystal.h>

//LCD
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//7SEG DISPLAY
int LATCH = 5;
int CLOCK = 6;
int SERIALPIN = 4;

const byte numbers[] = {
  0b111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111
};

//OTHER

void setup() {
  //LCD
  lcd.begin(16, 2);
  lcd.print("Test!");

  //7SEG
  pinMode(SERIALPIN, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);

  //OTHER
  pinMode(13, OUTPUT); // turn off onboard diode
  Serial.begin(9600);
}

void loop() {
  countSeconds();
  delay(1000);
}

void countSeconds(){
    digitalWrite(LATCH, LOW);
    // int number = (millis()/1000%10);
    // Serial.println(number);
    shiftOut(SERIALPIN, CLOCK, LSBFIRST, numbers[0]); //for demonstration purposes display 0
    digitalWrite(LATCH, HIGH);
}

Any ideas what's wrong?

2
  • what happens if you exchange the two digitalWrite() program lines?
    – jsotola
    Commented Mar 27, 2023 at 0:09
  • 1
    Hard to tell but it looks like the reset pin is floating. Make sure it is tied high (or controlled by your MCU).
    – Mat
    Commented Mar 27, 2023 at 5:56

1 Answer 1

1

As @Mat pointed out, the reset pin on the shift register was not connected. I didn't realize I need to anchor it high. Solved all problems, I guess it was resetting unpredictably..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.