7 Segment Display with Arduino — Wiring, Code & Multiplexing

Welcome to this beginner-friendly Arduino tutorial on the seven segment display. By the end of the guide, you'll wire the module to an Arduino UNO, flash a short sketch, and read live values on the Serial Monitor — no prior electronics experience required.
Need this built for you? I do custom Arduino, ESP32 and Proteus projects from $15.
What you'll learn
- How the module works in plain language
- The exact parts you need and how to wire them safely
- The full Arduino IDE sketch with comments
- Common issues and how to fix them

Hardware you'll need
| Component | Qty | Notes |
|---|---|---|
| Arduino Uno | 1 | ATmega328P based |
| 7 Segment Display | 1 | Common Cathode/Anode |
| Resistors | 8 | 330Ω |
| Breadboard | 1 | Full size |
| Jumper Wires | 10+ | Male to Male |

Arduino code
Open the Arduino IDE, paste the sketch below into a new file, install any libraries the sketch #includes (Tools → Manage Libraries), select your board and COM port, then click Upload.
#include "SevSeg.h"
SevSeg sevseg;
void setup()
{
//Set to 1 for single-digit display
byte numDigits = 1;
//defines common pins while using multi-digit display. Left for single digit display
byte digitPins[] = {};
//Defines Arduino pin connections in order: A, B, C, D, E, F, G, DP
byte segmentPins[] = {9,8, 7, 6, 5, 4, 3, 2};
byte displayType = COMMON_CATHODE; //Use COMMON_ANODE for Common Anode display
bool resistorsOnSegments = true; //‘false’ if resistors are connected to common pin
//Initialize sevseg object. Use COMMON_ANODE instead of COMMON_CATHODE for CA display
sevseg.begin(displayType, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
}
void loop()
{
//Display numbers 0-9 with 1 seconds delay
for(int i = 0; i <= 10; i++)
{
if (i == 10)
{
i = 0;
}
sevseg.setNumber(i);
sevseg.refreshDisplay();
delay(1000);
}
}




How it works
The sketch initialises serial communication and the seven segment display driver in setup(), then in loop() it samples the sensor at a regular interval and prints the result to the Serial Monitor at 9600 baud. Open the Serial Monitor (Ctrl+Shift+M) after upload to see live readings.
Troubleshooting checklist
- No readings: verify the baud rate in Serial Monitor matches the sketch (usually 9600).
- Garbage characters: wrong baud rate or loose GND wire.
- Library not found: install the exact library referenced in the
#includeline via Library Manager. - Sensor not detected (I²C): run an I²C scanner sketch to confirm the address.
What to build next
Once the basic readout works, try logging values to an SD card, sending them over Wi-Fi with an ESP32, or pushing them to a Blynk IoT dashboard. Pair this module with our simulator round-up to prototype the circuit before soldering.
Stuck on your own build? Send me your Arduino / ESP32 / Proteus project on Fiverr — from $15, you don't pay if it doesn't work.
You may also like
Frequently Asked Questions
Q.Common anode or common cathode — does the Arduino code change?
Yes, the logic inverts. Common cathode segments light on HIGH; common anode segments light on LOW, so either swap HIGH/LOW in your sketch or write ~segment to invert.
Q.What resistor does a seven segment display need?
About 220–330 Ω per segment from a 5V Arduino. One resistor per segment — never one on the common pin, or brightness changes with the number of lit segments.
Q.How many Arduino pins does a 7 segment display use?
Eight for a single digit (a–g plus the decimal point) plus one per digit's common pin. A 4-digit display needs 12 pins directly, or only 3 with a TM1637/74HC595 driver.
Q.Can I drive a 4-digit display without multiplexing?
Not with a plain Uno pin budget. Multiplex the digits fast (~1 ms each) or use a TM1637 or MAX7219 driver module — it handles multiplexing and only needs 2–3 pins.
The Engineer Post
Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.
Related projects

Interfacing OLED Display with Arduino
Step-by-step Arduino tutorial: wire the oled display to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.

Water Level Sensor with Arduino
Step-by-step Arduino tutorial: wire the water level to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.

Interfacing 16x2 LCD with Arduino
Step-by-step Arduino tutorial: wire the tcs3200 colour to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.

Interfacing 16x2 LCD with Arduino
Step-by-step Arduino tutorial: wire the sound to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.

Rain Detection Sensor with Arduino
Step-by-step Arduino tutorial: wire the rain detection to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.
