Arduino 4-Digit 7-Segment LED Display
Arduino 4-Digit 7-Segment LED Display
HOME PROJECTS MINI PROJECTS ARDUINO FREE CIRCUITS TUTORIALS SYMBOLS DIY
REVIEWS CONTACT US
YOU ARE HERE: HOME / ARDUINO / ARDUINO 4-DIGIT 7-SEGMENT LED DISPLAY
7 Segment LED displays are used in many applications as front panel number indicators.
The most common applications are calculators, microwave ovens, electronic lab
equipment like function generators and frequency counters.
A 7 segment LED display consists of 7 LEDs arranged in such a way that it can display
numbers from 0 to 9. The arrangement of LEDs in the display can be either common
anode or common cathode.
In this project, a 4 – digit 7 – segment LED display is used to display numbers using
Arduino.
Either a compact module containing four 7- segment LED displays can be used or four
individual 7 – segment displays can be used by multiplexing them.
Select the Next Set of Arduino Projects You Want to Learn in Electronicshub:
Arduino Projects»
Table of Contents
1. Circuit Diagram
2. Components Required
3. Working of 4 – Digit 7 – Segment LED Display
4. Code
Circuit Diagram
Components Required
Arduino UNO — 1 [Buy Here]
4 – Digit compact 7 – segment LED display — 1(Or)7 – Segment LED display — 4
BC547 — 4
1KΩ — 4
100Ω — 4
Working of 4 – Digit 7 – Segment LED Display
A 7 – Segment LED display, as the name indicates, is an assembly of LED bars, where
each bar can be powered individually. Each LED bar is in the form of a hexagon and the
overall arrangement will be in the form of ‘8’.
The following figure shows a general representation of 7 – segment LED display with
dedicated names to each segment.
Each segment can be powered separately to display digits from 0 to 9. The following
figure shows the pattern of digits displayed by a 7 – segment LED display.
The equivalent circuit of a 7 – segment display in common anode and common cathode
configuration is shown below.
To determine whether the 7 – segment display is common anode or cathode, a small
test circuit can be built. The common terminal of the display is connected to a current
limiting resistor.
The resistor is given positive voltage and any of the segments (A to G) is connected to
ground. If the segment glows, then it is common anode display.
If the segment doesn’t glow, reverse the polarity of the supply and then it glows. This is a
common cathode display.
In this project, we are using a 4 – digit 7 – segment LED display. We can use a compact
4 – digit module or use four individual 7 – segment displays and multiplex them to make
a 4 – digit display.
Hence, only 8 pins will be sufficient to control all the eight segments of all four displays.
These eight pins are connected to eight pins of Arduino.
We assume that the selected 7 – segment module is of common cathode type. The four
common pins from four displays are connected to collector terminals of four different
transistors through current limiting resistors.
The emitter terminals of four transistors are connected to ground. The four base terminal
of the four transistors are connected to four pins of Arduino through current limiting
resistors.
The circuit diagram and written code are developed for common cathode type 7 –
segment LED display.
Code
2
3 #define A 2
4 #define B 3
5 #define C 4
6 #define D 5
7 #define E 6
8 #define F 7
9 #define G 8
10 #define DP 9
11
12 #define disp1 10
13 #define disp2 11
14 #define disp3 12
15 #define disp4 13
16
17 #define numbersegments { \
18 {1,1,1,1,1,1,0,0},\
19 {0,1,1,0,0,0,0,0},\
20 {1,1,0,1,1,0,1,0},\
21 {1,1,1,1,0,0,1,0},\
22 {0,1,1,0,0,1,1,0},\
23 {1,0,1,1,0,1,1,0},\
24 {1,0,1,1,1,1,1,0},\
25 {1,1,1,0,0,0,0,0},\
26 {1,1,1,1,1,1,1,0},\
27 {1,1,1,0,0,1,1,0},\
28 }
29
30 byte numbers[10][8] = numbersegments;
31 const int segments[8] = {A, B, C, D, E, F, G, DP};
32
33 void setup()
34 {
35 pinMode(A, OUTPUT);
36 pinMode(B, OUTPUT);
37 pinMode(C, OUTPUT);
38 pinMode(D, OUTPUT);
39 pinMode(E, OUTPUT);
40 pinMode(F, OUTPUT);
41 pinMode(G, OUTPUT);
42 pinMode(DP, OUTPUT);
43 pinMode(disp1, OUTPUT);
44 pinMode(disp2, OUTPUT);
45 pinMode(disp3, OUTPUT);
46 pinMode(disp4, OUTPUT);
47 digitalWrite(A, LOW);
48 digitalWrite(B, LOW);
49 digitalWrite(C, LOW);
50 digitalWrite(D, LOW);
51 digitalWrite(E, LOW);
52 digitalWrite(F, LOW);
53 digitalWrite(G, LOW);
54 digitalWrite(DP, LOW);
55 digitalWrite(disp1, LOW);
56 digitalWrite(disp2, LOW);
57 digitalWrite(disp3, LOW);
58 digitalWrite(disp4, LOW);
59 }
60
61 void loop()
62 {
64 {
66 {
68 {
70 {
77 }
78 }
79 }
80 }
81 }
82 }
83
84 void setsegments(int number, int digit, int ontime)
85 {
89 {
90 digitalWrite(segments[seg], HIGH);
91 }
92 else
93 {
94 digitalWrite(segments[seg], LOW);
95 }
96 }
97 digitalWrite(digit, HIGH);
98 delayMicroseconds(ontime);
99 digitalWrite(digit, LOW);
100 }
Arduino 4-Digit 7-Segment LED Display hosted with by GitHub view raw
You are free to use above code. Feel free to ask your doubts and questions in below
comment. Our technical person love to help you.
Related Posts:
Arduino 7 Segment Display Interface
Interfacing 7 Segment Display to 8051
Seven Segment Displays
2 Digit Up/Down Counter Circuit
8 Channel Quiz Buzzer Circuit using Microcontroller
Arduino 8x8 LED Matrix
FILED UNDER: ARDUINO
Comments
Reply
Reply
Shivraj muttagi says
AUGUST 27, 2016 AT 2:22 PM
Reply
Sangeetha says
APRIL 11, 2017 AT 7:16 AM
Reply
Reply
For me thank you that you make project good for student lean
Reply
Manikandan says
MARCH 21, 2018 AT 12:09 PM
I need an program code for arduino uno based 4digit 7 segment display using
decimal to binary output in 7segment display.
Please help us .
Reply
junaid says
APRIL 9, 2018 AT 12:19 PM
WHATEVER DO IT ASAP
THANKS IN ADVANCE
Reply
Ravi says
APRIL 10, 2018 AT 4:07 AM
You need to use Arduino IDE to upload the code to Arduino. Simply connect the
Arduino to the computer (through USB cable) and hit upload in the Arduino IDE.
It’ll take care of everything.
Reply
Reply
Ravi says
JULY 30, 2018 AT 2:08 AM
Hi,
Code is already uploaded in the page.
Reply
Amstrong says
DECEMBER 8, 2018 AT 9:27 PM
hey, this is really good. but can i get a help? im trying to build a counter but i have
issues.
Reply
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
POST COMMENT
KITS