// Pin definitions for the two seven-segment displays 
const int segmentPins1[] = {0, 1, 2, 3, 4, 5, 6,7}; // Pins for the first display (LSB) 
const int segmentPins2[] = {10, 11, 12, 13, A0, A1, A2, A3}; // Pins for the second display (MSB) 
 
// Common cathode values for each digit (0 to 9) 
const byte digitValues[10] = { 
  B11000000, // 0 
  B11111001, // 1 
  B10100100, // 2 
  B10110000, // 3 
  B10011001, // 4 
  B10010010, // 5 
  B10000010, // 6 https://oas.lpu.in/
  B11111000, // 7 
  B10000000, // 8 
  B10010000  // 9 
};
 
int counter = 1; 
 
void setup() { 
  // Set segment pins as output for both displays 
  for (int i = 0; i <= 7; i++) { 
    pinMode(segmentPins1[i], OUTPUT); 
    pinMode(segmentPins2[i], OUTPUT); 
  } 
} 
 
void loop() { 
  // Display the current counter value 
  displayNumber(counter); 
  delay(1000); // Display for 1 second 
   
  // Increment counter and reset if it reaches 100 
  counter = (counter + 1) % 100; 
} 
 
void displayNumber(int num) { 
  int tens = num / 10;
  int ones = num % 10;
   
  if (tens >= 0 && tens <= 9 && ones >= 0 && ones <= 9) { 
    byte valueTens = digitValues[tens]; 
    byte valueOnes = digitValues[ones]; 
     
    for (int i = 0; i < 8; i++) { 
      digitalWrite(segmentPins1[i], bitRead(valueOnes, i)); 
      digitalWrite(segmentPins2[i], bitRead(valueTens, i)); 
    } 
  } 
}