A 7-segment display is a display device made up of seven individual segments, primarily used to show numbers. To display letters, an LCD screen is more suitable. This type of display is commonly used in devices like calculators or alarm clocks.As the name suggests, a 7-segment display consists of seven individual segments. Each segment represents a portion of the display that, when lit, contributes to forming a digit. By turning on specific segments, different numbers can be displayed. With this type of display, it is possible to show digits from 1 to 9. The 7-segment display uses 8-bit encoding.Here is the circuit diagram for connecting the 7-segment display: // Definition of digit patterns (common cathode) for 0–9 const uint8_t digits[] = { 0b11000000, // 0 0b11111001, // 1 0b10100100, // 2 0b10110000, // 3 0b10011001, // 4 0b10010010, // 5 0b10000010, // 6 0b11111000, // 7 0b10000000, // 8 0b10011000 // 9 }; // Segment pins: A, B, C, D, E, F, G const uint8_t segment_pins[] = {2, 3, 4, 5, 6, 7, 8}; // Digit control pins (for 4-digit multiplexing) const uint8_t digit_pins[] = {10, 11, 12, 13}; void setup() { Serial.begin(115200); Serial.println("7-segment display without using PIO"); // Initialize all segment pins as OUTPUT for (int i = 0; i < 7; i++) { pinMode(segment_pins[i], OUTPUT); } // Initialize digit control pins as OUTPUT for (int i = 0; i < 4; i++) { pinMode(digit_pins[i], OUTPUT); } } // Display a single digit at a specific position (0–3) void displayDigit(uint8_t digit, uint8_t position) { for (int i = 0; i < 7; i++) { digitalWrite(segment_pins[i], (digits[digit] >> i) & 0x01); } // Activate only the selected digit (common cathode: LOW = ON) for (int i = 0; i < 4; i++) { digitalWrite(digit_pins[i], (i == position) ? LOW : HIGH); } } // Display a 4-digit number by multiplexing void displayNumber(uint16_t number) { for (int i = 0; i < 4; i++) { displayDigit(number / pow(10, 3 - i) % 10, i); delay(5); // Short delay for persistence of vision } } int i = 0; void loop() { displayNumber(i++); if (i > 9999) i = 0; // Reset to 0 after reaching 9999 delay(200); // Delay between increments }