4 digit 7 segment x 2 row

Hello!
I have a problem about write code for 4 digit 7 segment x 2 row (as my picture) for make Production control board (Target and Actual score), i found code of 4 digit 7 segment for 1 row
but I need modify to 2 row http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265669651
I don’t know to modify someone can you help me.
Thanks a lot of.
this my circuit

I tried to modify code

/*
  Testing SparkFun's 4-digit 7-Segment Display (Blue)
 */

int segmentA = 0; // Segments A thru P == pins 0 thru 7
int digit0 = 10; // Digits 3 thru 0 == pins 10 thru 13 (0 is LEFT most digit)
int digit1 = 30; // Digits 3 thru 0 == pins 30 thru 33 (0 is LEFT most digit)
/*
10 digits:
 Each defines which segments should be on/off for that digit: A,B,C,D,E,F,G,P
 */
byte numbers[10] =
{
  B11000000, // 0
  B11111001, // 1
  B10100100, // 2
  B10110000, // 3
  B10011001, // 4
  B10010010, // 5
  B10000010, // 6
  B11111000, // 7
  B10000000, // 8
  B10010000  // 9
};

void setup()
{
  for (byte segment = 0; segment < 8; segment++)
    pinMode(segmentA+segment,OUTPUT);

  for (byte digit = 0; digit < 4; digit++)
    pinMode(digit0+digit,OUTPUT);
  for (byte digits = 0; digits < 4; digits++)
    pinMode(digit1+digits,OUTPUT);
}

int perDigitTime = 100;
int digitPosition = 1;  // Start anywhere but zero so we won't crash when we try to turn off previous digit.
int digitPosition2;
unsigned long previousMillis = 0;

int value = 0;
int value2=0;
int powerOfTen[] = {1,10,100,1000};

void RefreshDisplay()
{
  digitalWrite(digit0 + digitPosition, LOW);  // Turn off previous digit
  digitalWrite(digit1 + digitPosition, LOW);  // Turn off previous digit
  digitPosition++;

    if (digitPosition > 3)  

     digitPosition = 0;
  
  int digitValue = value % powerOfTen[ digitPosition+1 ] / powerOfTen[digitPosition];
  int number =  numbers[ digitValue ];
  
  int digitValue2 = value2 % powerOfTen[ digitPosition+1 ] / powerOfTen[digitPosition];
  int number2 =  numbers[ digitValue2 ];
  

  if ((number > 0) || (value < powerOfTen[ digitPosition+1 ]))

{
 
  for (byte seg = 0; seg < 8; seg++)
    digitalWrite(segmentA+seg, bitRead(number, seg) );
    digitalWrite(digit0 + digitPosition, HIGH);
     delay(4);

}


  if ((number2 > 0) || (value2 < powerOfTen[ digitPosition+1 ]))

{

  for (byte seg2 = 0; seg2 < 8; seg2++)
    digitalWrite(segmentA+seg2, bitRead(number2, seg2) );
    digitalWrite(digit1 + digitPosition, HIGH);
    delay(4);

}

}

void loop()
{
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > perDigitTime)
  {
    previousMillis = currentMillis;
    value++;

  }
  value2=1234;
  RefreshDisplay();
}

Hi matsuo,

The image of your circuit is to small to read the pin names the 7 segments are connected to, can you supply a better image please.

Hi Riva I change my circuit image. my condition of program is separate 4 digit 7 segment to 2 row as my picture. - Top row is "actual score" --- Digit 1 - 4 ( digital pin 30-33) - Below row is "target score" ---- Digit 1- 4 ( digital pin 10-13 ) - Segment pin--- A - G ( digital pin 0-6 ) How to program by scan time or another way ?

Hi matsuo, I was more interested in the way the segments are connected to your MCU (ATMega1280?) Are the D?? values in the schematic the pin numbers? Looking at the code, your trying to combine updating the upper and lower 7 segment displays at the same time but this won't work properly as the A-G segments are common between both displays. You either have to duplicate the RefreshDisplay() routine so one deals with the upper display and the other with the lower display or treat the display as 1x 8 digits instead of 2x 4 digits.

Another problem with that code is that you do all the conversion from a number to seven segment code inside the refresh routine. You want to have data that the refresh command uses. Then when you want to change the number you change that data. That cuts down on the processing and allows a faster refresh rate. Have a look at these two pages:- http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html