const uint8_t segmentCodes[] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F }; const int segmentPins[] = {2, 3, 4, 5, 6, 7, 8}; void setup() { for (int i = 0; i < 7; i++) { pinMode(segmentPins[i], OUTPUT); } } void displayDigit(int digit) { if (digit < 0 || digit > 9) return; uint8_t segments = segmentCodes[digit]; for (int i = 0; i < 7; i++) { digitalWrite(segmentPins[i], (segments >> i) & 0x01); } } void loop() { for (int i = 0; i <= 9; i++) { displayDigit(i); delay(1000); } }