2 Digit (individual not multiplexed) 7 Segments Display

Hello, I’m trying to make a 0 to 99 counter with 2 individual 7 segments display but i didn’t multiplexed the segments i buyed a chipkit max32 that has 82 I/O pins, and i connected the segments directly on the chipkit i tried this code:

int num_array[10][7] = {  { 1,1,1,1,1,1,0 },    // 0
                          { 0,1,1,0,0,0,0 },    // 1
                          { 1,1,0,1,1,0,1 },    // 2
                          { 1,1,1,1,0,0,1 },    // 3
                          { 0,1,1,0,0,1,1 },    // 4
                          { 1,0,1,1,0,1,1 },    // 5
                          { 1,0,1,1,1,1,1 },    // 6
                          { 1,1,1,0,0,0,0 },    // 7
                          { 1,1,1,1,1,1,1 },    // 8
                          { 1,1,1,0,0,1,1 }};   // 9
                                       
//function header
void Num_Write(int);

void setup() 
{ 
  // set pin modes
  
  pinMode(85, OUTPUT);  // Asignación de las salidas digitales
  pinMode(84, OUTPUT);
  pinMode(83, OUTPUT);
  pinMode(82, OUTPUT);
  pinMode(81, OUTPUT);
  pinMode(80, OUTPUT);
  pinMode(79, OUTPUT);
 
}

void loop() 
{
  
  //counter loop
  
  for (int counter = 10; counter > 0; --counter) 
  {
   delay(1000);
   Num_Write(counter-1); 
  }
  delay(3000);
}

// this functions writes values to the sev seg pins  
void Num_Write(int number) 
{
  int pin= 85;
  for (int j=0; j < 7; j++) {
   digitalWrite(pin, num_array[number][j]);
   pin--;
  }
}

this work for 1 display but when i try this:

void setup()
{
  pinMode(85, OUTPUT);  // Asignación de las salidas digitales
  pinMode(84, OUTPUT);
  pinMode(83, OUTPUT);
  pinMode(82, OUTPUT);
  pinMode(81, OUTPUT);
  pinMode(80, OUTPUT);
  pinMode(79, OUTPUT);
  pinMode(77, OUTPUT);  // Asignación de las salidas digitales
  pinMode(76, OUTPUT);
  pinMode(75, OUTPUT);
  pinMode(74, OUTPUT);
  pinMode(73, OUTPUT);
  pinMode(72, OUTPUT);
  pinMode(71, OUTPUT);
}
//The line below is the array containing all the binary numbers for the digits on a SSD from 0 to 9
const int number[11] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000};

void loop()
{
  for (int tens = 0; tens < 10; tens++)

  {
    display_tens(tens);
  }
}

void display_tens(const int tens)
{
  int pin1, a, ones;     
  //pin1 is just used to deal with pins of the 1st SSD which desplays the tens digit

  for (pin1 = 85, a = 0; pin1 > 78; pin1--, a++)
  {
    digitalWrite(pin1, bitRead(number[tens], a));
  }
  for (ones = 0; ones < 10; ones++)
  {
    display_ones(ones);
    delay(300); 
    //I have given a delay of 300 milliseconds. You can put your own Time!!
  }
}

void display_ones(const int x)
{ int pin2, b;             
//pin2 is just used to deal with pins of the 2nd SSD which desplays the ones digit

  for (pin2 = 77, b = 0; pin2 >= 71; pin2--, b++)
  {
    digitalWrite(pin2, bitRead(number[x], b));

  }

}

Don’t work correctly

How i can’t make it work

The pins 85 to 79 are for the display 1 and the pins 77 to 71 are for the display 2 (decimals), they are ordered from a to g.

what am i doing wrong?

Thank you for your help.

This looks messed up to me:

for (pin1 = 85, a = 0; pin1 > 78; pin1--, a++)

I don't believe you can have multiple arguments for the various parts of the for(). But, I could be wrong.

What does it actually do and how does it not match your expectations?

You have number array declared to have 11 elements but 0 to 9 is 10 elements.

Which segment (a - f) on the digit is connected to which pin? Which 7-segment display are you using?

wvmarle: What does it actually do and how does it not match your expectations?

He has 2 digits.

I believe he wants to be able to count from 0 to 9 for each digit.

He is using the numbers array to contain 1 or 0 for which segment in a digit is turned on/off.

Should be simple since he has a Mega 2560.

The chipKit Max32 actually has a PIC microcontroller and he needs a plug-in to be able to use the Arduino IDE to program it.

Don't work correctly

Do you have current limiting resistors for each display segment? If not, you will destroy the Arduino.

jremington: Do you have current limiting resistors for each display segment? If not, you will destroy the Arduino.

He doesn't have an Arduino; he has a chipKit Max32 which is Arduino Mega form-factor.

I don't believe you can have multiple arguments for the various parts of the for().

In the case of the "comma operator", you certainly can.

He doesn't have an Arduino; he has a chipKit Max32 which is Arduino Mega form-factor.

Then he will destroy the PIC instead.

jremington: Then he will destroy the PIC instead.

Yep.

I wonder if he even installed the plug-in. Not that it is the cause of his programming problem, but it will get good code to work.

jremington: In the case of the "comma operator", you certainly can.

Well, I'll be!

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)