Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Project 27: 7 Segment Display (1 Digit)

Introduction

A 7-segment display is used to show numeric digits using 7 LEDs (segments) labeled a–g.
Each segment lights up individually to form numbers from 0 to 9.
It comes in Common Cathode or Common Anode types.
Today, we’ll learn to connect and control a 1-digit 7-segment display with Arduino Uno.

Required Components

  • Arduino UNO
  • 7 Segment Display
  • 220 Ohm Resistor (8 Pcs)
  • Jumper wires
  • Breadboard

Pinout

Circuit Diagram / Wiring

  • Segment (a) → Arduino 2
  • Segment (b) → Arduino 3
  • Segment (c) → Arduino 4
  • Segment (d) → Arduino 5
  • Segment (e) → Arduino 6
  • Segment (f) → Arduino 7
  • Segment (g) → Arduino 8
  • Segment (DP) → Arduino 9
  • Segment (GND) → Arduino GND
  • Use 220Ω resistors between each segment pin and the Arduino to limit current.

Arduino Code / Programming

int segments[] = {2, 3, 4, 5, 6, 7, 8};
byte digits[10][7] = {
  {1,1,1,1,1,1,0}, // 0
  {0,1,1,0,0,0,0}, // 1
  {1,1,0,1,1,0,1}, // 2
  {1,1,1,1,0,0,1}, // 3
  {0,1,1,0,0,1,1}, // 4
  {1,0,1,1,0,1,1}, // 5
  {1,0,1,1,1,1,1}, // 6
  {1,1,1,0,0,0,0}, // 7
  {1,1,1,1,1,1,1}, // 8
  {1,1,1,1,0,1,1}  // 9
};

void setup() {
  for (int i = 0; i < 7; i++) {
    pinMode(segments[i], OUTPUT);
  }
}

void loop() {
  for (int num = 0; num <= 9; num++) {
    for (int i = 0; i < 7; i++) {
      digitalWrite(segments[i], digits[num][i]);
    }
    delay(1000);
  }
}

Explanation

  • The segments[] array stores Arduino pin connections to each segment.
  • The digits[][] array defines segment states for numbers 0–9.
  • loop() cycles through 0–9 and lights the segments accordingly.

Testing & Troubleshooting

  • If the number doesn’t show correctly, check segment-to-pin connections.
  • Use a multimeter to verify whether your display is common cathode or anode.
  • Dim display? Ensure you’re not drawing too much current from Arduino.

    Leave a Reply

    Your email address will not be published.

    Need Help?