Issue whit 7 segment 4 digit display and whit 2 x 74HC595 code programing

I have an Issu whit the folowing schematics and code for it. What i have found on this forum the schematics its good or "I think it's good."

image

the original code it's the folowing.

int clockPin[] = {7,10,13};
int latchPin[] = {6,9,12};
int dataPin[] = {5,8,11};

byte digits[] =   {B00001100, //0
                   B10111101, //1
                   B01101000, //2
                   B00111000, //3
                   B10011001, //4
                   B00011010, //5
                   B00001010, //6
                   B10111100, //7
                   B00001000, //8
                   B00011000  //9
                  };

int digit1, digit2, digit3, digit4;

void setup() {

  pinMode(clockPin[0], OUTPUT);
  pinMode(latchPin[0], OUTPUT);
  pinMode(dataPin[0], OUTPUT);

  pinMode(clockPin[1], OUTPUT);
  pinMode(latchPin[1], OUTPUT);
  pinMode(dataPin[1], OUTPUT);

  pinMode(clockPin[2], OUTPUT);
  pinMode(latchPin[2], OUTPUT);
  pinMode(dataPin[2], OUTPUT);
  
}

void loop() {

  showNumber(756,0);
  showNumber(74,1);

}


void showNumber (int num, int disp) {
  
  digit4 = num % 10;
  digit3 = (num / 10) % 10;
  digit2 = (num / 100) % 10;
  digit1 = (num / 1000) % 10;
 
  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00001000); // X X X NUM
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit4]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00000100); // X X NUM X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit3]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00000010); // X NUM X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit2]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1);
  
  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00000001); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit1]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1);
    
}

But so dosen't work for me. The binari code for the numbers 1.2.3.4.5.6.7.8.9. was for me wrong. And the digits 1-4 on the original code have by Me not working corentli. so hawe I modifide the code and so working it for me at the moment but i think it's not the correkt way to work normali the code. So I don't no what it's wrong ore waht can I do that it's working corektly. My code currently it's this wath for mMe currently work.

int clockPin[] = {7};
int latchPin[] = {6};
int dataPin[] = {5};

byte digits[] =   { 
    B11111011, // 0
    B01000010, // 1
    B10010111, // 2
    B11001111, // 3
    B01101110, // 4
    B11101101, // 5
    B11111101, // 6
    B01001011, // 7
    B11111111, // 8
    B11101111  // 9
                  };

int digit0, digit1, digit2, digit3, digit4, digit5, digit6,digit7, digit8, digit9;

void setup() {

  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  
}





void loop() {

  showNumber(9990,0);
  showNumber(1,0);
  delay(1000);      // Delay for 1 second


}


void showNumber (int num, int disp) {

  digit1 = (num /  55) % 10;
  digit2 = (num / 97 ) % 10;
  digit3 = (num / 14) % 10;
  digit4 = (num / 23) % 10;
  digit5= (num / 2) % 10;
  digit6= (num / 24) % 10;
  digit7= (num / 4) % 10;
  digit8= (num / 8) % 10;
  digit9= (num / 10) % 10;

    digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit1]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);
  
  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // X X X NUM
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit2]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // X X NUM X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit3]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // X NUM X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit4]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);
  
  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit5]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit6]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit7]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit8]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

  digitalWrite(latchPin[disp], LOW);
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, B00010000); // NUM X X X
  shiftOut(dataPin[disp], clockPin[disp], MSBFIRST, digits[digit9]);
  digitalWrite(latchPin[disp], HIGH);
  delay(1000);

 

}

I'm a beginer on this arduino world and it's my first projekt with arduino. And so I need still have a lot to learn in this area.

looks like you expect to call a routine one time and have it display multiple digits. to do that requires driving the a-g pins of 4 separate 7 segment displays. that of course would require 28 separate pins or 4 separate shift registers.

but you have a multiplexed display. the shift register drives a common set of a-g pins and it is expected to enable just one display digit.

in order to display multiple digits, each digit of the display is expected to be repeatedly briefly driven. our eyes will see all the digits displayed, our eyes won't notice when each display digit is dark

the code can enable a timer to generate an interrupt to shift values out for each digit. The main program calls some function to display a 4 digit value. That function copies each digit into a 4 element array. The interrupt repeated and sequentially retrieves a value from the array, determines the a-g values and the bit to enable that display digit and shifts the values out

the Arduino multi-function shield has a multiplexed display. you can find code to drive it from that site.

You should have the current limiting resistors from the segment drivers, not the digit drivers. As you have it the resistors will limit the total current, but the different segment could use different amounts which would affect their brightness.

Whit the brightness have I no Issus I use 1k Resistors for the segments for me it's so fine the Level of the dimming. And I don't us the dot pin on the schematics. But thanks for the answer.

Thanks for the Tip I will later luck it and hop that it's good for my Issu

Your setup might want to see the bits LSB first versus MSB first.

Your bit arrays are not set up for "a, b, c, d, e, f, g, dp"... for example, your "1" says B10111101

 ---
|    
|   |
 ---o

when it should be B01100000 (or maybe B00000110)

    |
    |

The Binari code on my "program" or code it's currently for the 7 segegment 4 digits Common-Cathode display what i use The 3461as-1 good. I changed the position of the segments manually with the code. I think it's the original schematics wrong for this Issu if normally all displays should work with the original binary code

sorry for the bad picture my camera failed while taking the picture

Are you using the RexQualis UNO R3 Super Starter Kit? I am quite sure this lesson will not let use different numbers, rather, only one number, four times.

No I have an arduino nano clone the 7 segment 4 digits display the breadboard and the two sn74hc595 . I bought all the elements of the project separately, not in a set. Later make I a new test board whit a diferent wiring for the segments and after that will make a test with the normal binari code that so works correntli or not

Here is an example (simulation) of a 4-digit 7-segment display with two 74HC595 shift registers. Maybe this will help or give you some ideas...

One big difference is that SPI is used to transfer the data to the shift register. That's why the pin assignments on the Arduino are different.

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