Bench NotesUno handbook

Seven-Segment Character Display: LUCE

Spell L-U-C-E on one common-cathode seven-segment digit using pins 2–9.

IntermediateSeven-segmentResistor

Overview

A single seven-segment digit spells the word LUCE one letter at a time, holding each for a second, then goes dark for half a second before starting again. Each letter is stored as a row of eight 1s and 0s, one per segment.

You will need

  • Arduino Uno R3 and USB cable
  • One common-cathode seven-segment display (0.56" is typical)
  • 8 × 330 Ω resistors (220–1 kΩ is fine)
  • Breadboard and jumper wires

Wiring

Uno pinConnects toNotes
2Segment a (top) through 330 ΩHIGH = lit
3Segment b (upper right) through 330 ΩHIGH = lit
4Segment c (lower right) through 330 ΩHIGH = lit
5Segment d (bottom) through 330 ΩHIGH = lit
6Segment e (lower left) through 330 ΩHIGH = lit
7Segment f (upper left) through 330 ΩHIGH = lit
8Segment g (middle) through 330 ΩHIGH = lit
9Segment dp (decimal point) through 330 ΩHIGH = lit
GNDDisplay common cathode (COM)Usually two COM pins; connect one or both.
Wiring for Seven-Segment Character Display: LUCEArduino Uno D2 to Common-cathode display segment a through 330 Ω; Arduino Uno D3 to Common-cathode display segment b through 330 Ω; Arduino Uno D4 to Common-cathode display segment c through 330 Ω; Arduino Uno D5 to Common-cathode display segment d through 330 Ω; Arduino Uno D6 to Common-cathode display segment e through 330 Ω; Arduino Uno D7 to Common-cathode display segment f through 330 Ω; Arduino Uno D8 to Common-cathode display segment g through 330 Ω; Arduino Uno D9 to Common-cathode display segment dp through 330 Ω; Arduino Uno GND to Common-cathode display COM (common cathode).Connections (each line is one wire)Arduino UnoCommon-cathode displayD2segment a330 ΩD3segment b330 ΩD4segment c330 ΩD5segment d330 ΩD6segment e330 ΩD7segment f330 ΩD8segment g330 ΩD9segment dp330 ΩGNDCOM (common cathode)
Original wiring diagram. Each line is one jumper wire; boxes on a line are series resistors.

How the pins are arranged

Read before wiring

The display must be a common-cathode seven-segment digit. Its common pin goes to GND and each segment lights when its Uno pin is HIGH (active-high). The pattern arrays list the eight segments in the order a, b, c, d, e, f, g, dp, which the sketch maps to pins 2 through 9: characterPatterns[i][segmentPin - 2].

Every segment needs its own resistor (220–1 kΩ; 330 Ω is a good default). Do not use a single resistor on the common pin: the brightness would change with the number of lit segments. On a common-anode display the logic is reversed (common to 5V, segment on when LOW), so this sketch would show the inverse of each letter. See Common anode vs common cathode.

Segment pin positions differ between display models. Check the datasheet for your part, or find each segment with a 5 V supply and a 1 kΩ resistor before wiring.

Diagrams

Segment-to-pin mapSeven-segment digit with segments labelled a (top), b (upper right), c (lower right), d (bottom), e (lower left), f (upper left), g (middle) and dp (decimal point). segment a to pin 2, segment b to pin 3, segment c to pin 4, segment d to pin 5, segment e to pin 6, segment f to pin 7, segment g to pin 8, segment dp to pin 9.agdfbecdpSegment → Uno pinapin 2via 330 Ωbpin 3via 330 Ωcpin 4via 330 Ωdpin 5via 330 Ωepin 6via 330 Ωfpin 7via 330 Ωgpin 8via 330 Ωdppin 9via 330 Ωcommon cathode (common pin to GND)
Segment names and the Uno pin that drives each one.
Characters and their segment patternsThe display shows, one second each: L (segments d, e, f), U (segments b, c, d, e, f), C (segments a, d, e, f), E (segments a, d, e, f, g), then goes blank for half a second.L: 00011100U: 01111100C: 10011100E: 10011110
The four patterns from the sketch, as they appear on the display.

The sketch

seven_segment_luce.ino
int segmentPin;
int characterPatterns[4][8] = {
  {0,0,0,1,1,1,0,0}, // L
  {0,1,1,1,1,1,0,0}, // U
  {1,0,0,1,1,1,0,0}, // C
  {1,0,0,1,1,1,1,0}  // E
};

void setup() {
  for (segmentPin = 2; segmentPin <= 9; segmentPin++) {
    pinMode(segmentPin, OUTPUT);
    digitalWrite(segmentPin, LOW);
  }
}

void loop() {
  for (int characterIndex = 0; characterIndex < 4; characterIndex++) {
    for (segmentPin = 2; segmentPin <= 9; segmentPin++) {
      digitalWrite(segmentPin, characterPatterns[characterIndex][segmentPin - 2]);
    }
    delay(1000);
  }
  for (segmentPin = 2; segmentPin <= 9; segmentPin++) {
    digitalWrite(segmentPin, LOW);
  }
  delay(500);
}

How the code works

The outer loop walks through the four letters; the inner loop writes all eight segments for the current letter. segmentPin - 2 converts a pin number (2–9) into an array column (0–7). Writing a 1 with digitalWrite() is the same as writing HIGH.

Review result: no changes were needed. We decoded every row against the a–g, dp order: L lights d, e, f; U lights b, c, d, e, f; C lights a, d, e, f; E lights a, d, e, f, g. All four are correct for a common-cathode display.

What you should observe

  • L, U, C and E appear in turn, one second each, then the display is blank for half a second.
  • The decimal point never lights (its column is 0 in every row).
  • If you see the letters "inside out" (everything lit except the letter), your display is common-anode.
  • If the shapes are scrambled, two or more segment wires are swapped; compare against the segment map.