7 Segment Display with Arduino (Common Cathode)Âļ
TinkerCad project link
Seven Segment DigitsÂļ
/*
Pins used: Arduino 2 to 9
*/
byte pin[] = {2, 3, 4, 5, 6, 7, 8, 9}; // Arduino pin array
// Corrected binary patterns for a Common Cathode display (1 = ON, 0 = OFF)
int number[10][8] = {
{1, 1, 1, 1, 1, 1, 0, 0}, // 0
{0, 1, 1, 0, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1, 0}, // 2
{1, 1, 1, 1, 0, 0, 1, 0}, // 3
{0, 1, 1, 0, 0, 1, 1, 0}, // 4
{1, 0, 1, 1, 0, 1, 1, 0}, // 5
{1, 0, 1, 1, 1, 1, 1, 0}, // 6
{1, 1, 1, 0, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1, 0}, // 8
{1, 1, 1, 1, 0, 1, 1, 0} // 9
};
void setup() {
for (byte a = 0; a < 8; a++) {
pinMode(pin[a], OUTPUT); // Define output pins
}
}
void loop() {
for (int a = 0; a < 10; a++) { // Loops through all 10 digits (0-9)
for (int b = 0; b < 8; b++) {
digitalWrite(pin[b], number[a][b]); // Display numbers
}
delay(1000); // Wait 1 second before switching numbers
}
}

