// Define the pins for each segment (a to g) and the common cathode pin
const int segmentPins[8] = {2, 3, 4, 5, 6, 7, 8};
const int commonCathodePin = 9;

// Define the numbers to display on the seven-segment display
const byte numbers[11] = {
  B11111100, // 0
  B01100000, // 1
  B11011010, // 2
  B11110010, // 3
  B01100110, // 4
  B10110110, // 5
  B10111110, // 6
  B11100000, // 7
  B11111110, // 8
  B11110110  // 9
};

void setup() {
  // Set segment pins as outputs
  for (int i = 0; i < 7; i++) {
    pinMode(segmentPins[i], OUTPUT);
  }

  // Set common cathode pin as output
  pinMode(commonCathodePin, OUTPUT);
}

void loop() {
  // Count from 0 to 9
  for (int i = 0; i < 10; i++) 
  {
    displayNumber(i);
   // while(1);
    delay(1000); // Display each number for 1 second

   // for (int j = 0; j < 8; j++) {
   // digitalWrite(segmentPins[j], LOW);
  //}
  }
}

// Function to display a digit on the seven-segment display
void displayNumber(int num) {
  // Turn off all segments
  for (int i = 0; i < 8; i++) {
    digitalWrite(segmentPins[i], HIGH);
  }

  // Activate segments based on the number to be displayed
  for (int i = 0; i < 8; i++) {
    if (bitRead(numbers[num], i) == LOW) {
      digitalWrite(segmentPins[7-i], LOW);
    }
  }

  // Turn on the common cathode to display the digit
 // digitalWrite(commonCathodePin, LOW);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
sevseg1:COM.1
sevseg1:COM.2
sevseg1:A
sevseg1:B
sevseg1:C
sevseg1:D
sevseg1:E
sevseg1:F
sevseg1:G
sevseg1:DP