Green University of Bangladesh (GUB)
Department of Electrical and Electronic Engineering [EEE]
Faculty of Sciences & Engineering
Semester: Summer Year: 2025, B.Sc. in EEE (Regular)
Lab Report
Course Name: Integrated design project II
Course Code: EEE-444 Section: 221pc-D1 Batch: 221
Experiment No. 05
Experiment Name : Digital Counter Implementation using Seven Segment Display
Student Details
Name ID
Md. Shakil Hossain 221901023
Date of Performance : 08.07.2025
Date of Submission : 15.07.2025
Course Teachers Name & Designation: Monjila Afrin Dorothi
Lecturer Dept. of EEE, GUB.
General Instructions:
(i) Don’t write anything behind the cover page.
(ii) Don’t copy your Laboratory reports from anyone.
(iii) Check deadlines before submission.
(iv) Handwriting should be legible. Avoid spelling mistakes & Grammatical errors in the laboratory report.
(v) Incomplete submission of the Laboratory report will not be accepted.
[For Teachers use only: Don’t Write Anything inside this box]
Lab Report
Marks: status Signature:
………………………………………….. …………………………….
Comments: Date:
1. Arduino code to display numbers from 0 to 9 on a seven-segment
display:
// Pin connections for 7-segment
display int segA = 6;
int segB =
7; int segC
= 8; int
segD = 2;
int segE =
3; int segF
= 5; int
segG = 4;
int digits[10][7] = {
{LOW, LOW, LOW, LOW, LOW, LOW, HIGH}, // 0
{HIGH, LOW, LOW, HIGH, HIGH, HIGH, // 1
HIGH},
{LOW, LOW, HIGH, LOW, LOW, HIGH, // 2
LOW},
{LOW, LOW, LOW, LOW, HIGH, HIGH, // 3
LOW},
{HIGH, LOW, LOW, HIGH, HIGH, LOW, // 4
LOW},
{LOW, HIGH, LOW, LOW, HIGH, LOW, LOW}, // 5
{LOW, HIGH, LOW, LOW, LOW, LOW, LOW}, // 6
{LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH}, // 7
{LOW, LOW, LOW, LOW, LOW, LOW, LOW}, // 8
{LOW, LOW, LOW, LOW, HIGH, LOW, LOW} // 9
};
void setup() {
// Set all pins for the 7-segment display as
output pinMode(segA, OUTPUT);
pinMode(segB,
OUTPUT);
pinMode(segC,
OUTPUT);
pinMode(segD,
OUTPUT);
pinMode(segE,
OUTPUT);
pinMode(segF,
OUTPUT);
pinMode(segG,
OUTPUT);
void loop() {
for (int i = 0; i <= 9; i++)
{ displayNumber(i);
delay(1000); // Delay for 1 second before changing number
}
}
void displayNumber(int num) {
int* segments = digits[num];
digitalWrite(segA,
segments[0]);
digitalWrite(segB,
segments[1]);
digitalWrite(segC,
segments[2]);
digitalWrite(segD,
segments[3]);
digitalWrite(segE,
segments[4]);
digitalWrite(segF,
Output:
Figure 1: Circuit Diagram for displaying numbers from 0 to 9 on a seven-segment dispSimulation)
Task 1: Arduino code to display numbers from 0 to 9 on a seven-segment
display(for CC-display):
// Pin connections for each
segment const int segA = 6;
const int segB =
7; const int segC
= 8; const int
segD = 2; const
int segE = 3;
const int segF =
5; const int segG
= 4;
// Digit encoding for common cathode display (0–9)
// HIGH = ON, LOW = OFF
const int digits[10][7] = {
{HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}, // 0
{LOW, HIGH, HIGH, LOW, LOW, LOW, LOW}, // 1
{HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH}, // 2
{HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH}, // 3
{LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH}, // 4
{HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH}, // 5
{HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}, // 6
{HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW}, // 7
{HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}, // 8
{HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH} // 9
};
void setup() {
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
}
void loop() {
for (int i = 0; i <= 9; i+
+) { displayNumber(i);
delay(1000);
}
}
void displayNumber(int num) {
digitalWrite(segA, digits[num]
[0]); digitalWrite(segB,
digits[num][1]);
digitalWrite(segC, digits[num]
[2]); digitalWrite(segD,
digits[num][3]);
digitalWrite(segE, digits[num]
[4]); digitalWrite(segF,
digits[num][5]);
Output:
Task-2: Modify the given code so that after displaying 9, it decreases to 0 with step
size 1.
// Pin connections for each segment
const int segA = 6;
const int segB = 7;
const int segC = 8;
const int segD =
2; const int segE
= 3; const int
segF = 5; const
int segG = 4;
// Digit encoding for common cathode display
(0–9) const int digits[10][7] = {
{HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}, // 0
{LOW, HIGH, HIGH, LOW, LOW, LOW, LOW}, // 1
{HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH}, // 2
{HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH}, // 3
{LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH}, // 4
{HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH}, // 5
{HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}, // 6
{HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW}, // 7
{HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}, // 8
{HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH} // 9
};
void setup() {
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
}
void loop() {
// Count up from 0 to 9
for (int i = 0; i <= 9; i+
+) { displayNumber(i);
delay(1000);
}
// Count down from 9 to 0
for (int i = 9; i >= 0;
i--) { displayNumber(i);
delay(1000);
}
}
void displayNumber(int num) {
digitalWrite(segD, digits[num][3]);
digitalWrite(segA, digits[num][0]);
digitalWrite(segB, digits[num][1]);
digitalWrite(segC, digits[num]
[2]); digitalWrite(segE,
digits[num][4]);
digitalWrite(segF, digits[num]
[5]); digitalWrite(segG,
digits[num][6]);
Output
Figure 1: Circuit Diagram and Code. After displaying 9, the value decreases to 0 with a step size of 1.
(After-Simulation).
Task-03: Prepare a list of alphabets that can be displayed using a seven-segment
display. Include the LED status table for each of them.
// Segment pin definitions
const int segA =
6; const int segB
= 7; const int
segC = 8; const
int segD = 2;
const int segE =
3; const int segF
= 5;
// Characters that can be displayed on a 7-segment display
const char letters[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'L', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'Y', 'Z'};
const int numLetters = sizeof(letters) / sizeof(letters[0]);
// Segment patterns for each character: {A, B, C, D, E, F,
G} const int segmentPatterns[][7] = {
{HIGH, HIGH, HIGH, LOW, HIGH, HIGH, HIGH}, // A
{LOW, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}, // B
{HIGH, LOW, LOW, HIGH, HIGH, HIGH, LOW }, // C
{LOW, HIGH, HIGH, HIGH, HIGH, LOW, HIGH}, // D
{HIGH, LOW, LOW, HIGH, HIGH, HIGH, HIGH}, // E
{HIGH, LOW, LOW, LOW, HIGH, HIGH, HIGH}, // F
{HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}, // G
{LOW, HIGH, HIGH, LOW, HIGH, HIGH, HIGH}, // H
{LOW, HIGH, HIGH, LOW, LOW, LOW, LOW }, // I
{LOW, HIGH, HIGH, HIGH, LOW, LOW, LOW }, // J
{LOW, LOW, LOW, HIGH, HIGH, HIGH, LOW }, // L
{HIGH, HIGH, HIGH, LOW, HIGH, HIGH, LOW }, // N
{HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW }, // O
{HIGH, HIGH, LOW, LOW, HIGH, HIGH, HIGH}, // P
{HIGH, HIGH, HIGH, LOW, LOW, HIGH, HIGH}, // Q
{HIGH, HIGH, LOW, LOW, HIGH, HIGH, LOW }, // R
{HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH}, // S
{LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH}, // T
{LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW }, // U
{LOW, HIGH, HIGH, HIGH, LOW, HIGH, HIGH}, // Y
{HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH} // Z
};
void setup() {
// Set segment pins as outputs
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
}
void loop() {
// Display each available letter
for (int i = 0; i < numLetters; i++) {
displayChar(segmentPatterns[i]);
delay(1000); // Wait for 1 second between letters
}
}
// Function to write a character pattern to the
segments void displayChar(const int pattern[7]) {
digitalWrite(segA,
pattern[0]);
digitalWrite(segB,
pattern[1]);
digitalWrite(segC,
pattern[2]);
digitalWrite(segD,
pattern[3]);
digitalWrite(segE,
pattern[4]);
Output:
Discussion: In this experiment, we successfully implemented a digital counter using a 7-segment
display and an Arduino microcontroller. The purpose was to visually display numeric values (0–9
and back) in a sequential manner, allowing us to understand the practical application of digital logic
and output interfacing.
The seven segment display used in this lab was a common cathode type, where each segment lights
up when a HIGH signal is provided. We programmed the Arduino to send digital signals to specific
segments based on the digit to be displayed. The logic mapping for each number (0–9) was manually
defined in the code using a 2D array, ensuring accurate representation on the display.
This project enhanced our understanding of:
Pin mapping and segment activation in 7-segment displays.
Binary-to-decimal representation.
Delay functions and loop structures in embedded programming.
Practical integration of hardware and software.
One limitation observed was that the current implementation supports only a single-digit display.
For multi-digit counting, additional logic (such as multiplexing or shift registers like 74HC595)
would be required.
Overall, the lab provided valuable hands-on experience with microcontroller-based output control,
digital electronics, and real-time display systems. It lays the foundation for more complex
applications like digital clocks, counters, and timers