Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595

|281x500

@paulRB, can you still help me? if dont bother you, i hope you give me the sample code please. tell me if you need more information.

Does the code you posted produce the digits shown in your picture? Do the digits change as the code runs?

my code is not working properly, still confused specify the position of digit, and I can not specify the columns and rows of each segment

You keep asking if you are bothering me. It bothers me when you ignore a question that I ask.

Here is some code to try:

int latchPin = 10;
int clockPin = 9;
int dataPin = 8;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {0, 1, 2, 3, 4, 5},
  {0, 0, 2, 4, 6, 8},
  {0, 1, 3, 5, 7, 9}
};


void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

void loop()
{
  updateShiftRegister();
}

void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    digitalWrite(latchPin, LOW);
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << column); // send the column enable mask
    digitalWrite(latchPin, HIGH);

    column++; // next time, we will light the next column
    if (column > 5) column = 0;
    lastUpdateTime = millis();
  }
}

It is unlikely that it will work correctly at the first attempt. I do not have your display and cannot test the code. I must rely on you to test it. This means you must be accurate and detailed in your description of any faults. Pictures, even video, may be useful.

forgive me if I made a mistake in this post, ok paul, I will try the example code you provided, I'm trying to learn and develop this code. If successful or not successful then I will tell you in this forum.

best regards for you

What was the result of testing my suggested code?

Are you going to post that schematic you received from the vendor? You should explain how the schematic is incorrect.

@paulRB Sorry for the late reply, I've tried the code you provided, but still not working (later show the picture), the vendor said the scheme was never published because it is still a beta version and say that schematic correct. I was told to wait for the release version for 2 weeks later.

zifank:
…say that schematic correct.

Remember those transistors that you checked with your meter and found out they were PNP? Where are they on the schematic?!?

yes, the vendor make me crazy !!!,,,

I think, I had to wait for 2 weeks for the answer.

thanks PaulRB for u support...

Anyway, you have not yet explained what happens when you run that code I have you.

this is result with your code

https://youtu.be/cgQGx81rPo8

You don’t use code tags to post links, you use link tags, like this. Did you read the forum guidelines yet? Please do that.

And why have you not posted that schematic? You only do half the things that I ask!

Try this

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+1)); // send the column enable mask
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);

paulRB, this is second result.

int latchPin = 4;
int clockPin = 3;
int dataPin = 2;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {0, 1, 2, 3, 4, 5},
  {0, 1, 2, 3, 4, 5},
  {0, 1, 2, 3, 4, 9}
};



void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  
}

void loop()
{
  
  updateShiftRegister();

}

void sevoff() {
  static byte column; // the column currently being lit
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 5)); // send the column enable mask
  for (byte row = 0; row < 3; row++) // update each row for the current column
  {
    shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// send the segment data for each row

  }
  digitalWrite(latchPin, HIGH);
}

void test() {
  static byte column; // the column currently being lit
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 0)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 1)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 2)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 3)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 4)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 5)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  digitalWrite(latchPin, HIGH);
}



void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+1)); // send the column enable mask
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);

    column++; // next time, we will light the next column
    if (column > 5) column = 0;
    lastUpdateTime = millis();
    delay(1000);
  }
}

video

Interesting, but not what I wanted to see. I wanted to see if the code I gave you worked. That video shows the code you added running. I can see why your code does not light the leftmost digit.

PaulRB: Interesting, but not what I wanted to see. I wanted to see if the code I gave you worked. That video shows the code you added running. I can see why your code does not light the leftmost digit.

agree, your code almost right. the light can't show the leftmost digit, how can i solved this?

maybe can you show me the code if the case is:

Row 1 (top, with 6 digits) show number "123.456" Row 2 (middle with 4 digit) show "78.90" Row 3 (bottom, with 5 digit) show "12.456"

thanks PaulRB, you are the Real Master..

Did you make the change I suggested in post #33? I hoped that would fix the leftmost digit.

If you take my code from post #25 and add the changes from post #33, what digits do you see displayed?

PaulRB: Did you make the change I suggested in post #33? I hoped that would fix the leftmost digit.

If you take my code from post #25 and add the changes from post #33, what digits do you see displayed?

I've changed the code in the post #25, and add the code in the post #33. the result is like in the video above, the display show a number from Array of displayBuffer are vertical not of horizontal.

paulRb, one more question of new case,

how to hold the first number in first digit, and the second digit show a second number, i’ve a trouble to keep first digit. show only a second digit from two number. can u give me simple code to keep/hold that first number in first digit?

or

maybe can you show me the code if the case is:

Row 1 (top, with 6 digits) show number “123.456”
Row 2 (middle with 4 digit) show “78.90”
Row 3 (bottom, with 5 digit) show “12.456”

I’m trying to learn the code.