0% found this document useful (0 votes)
66 views11 pages

Activity 4.1 Digital Output

Uploaded by

Aljiven Alejo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views11 pages

Activity 4.1 Digital Output

Uploaded by

Aljiven Alejo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

COMPUTER ENGINEERING DEPARTMENT


Quezon City

Activity Manual

Embedded Systems

Engr. Ryan D. Francisco, CCpE


Activity No. 4
Advance 7-Segment Interfacing
Course Code: CPE 014 Date Performed:9/14/24
Course Title: Embedded Systems Date Submitted:9/14/24
Section: CPE22S1 Instructor:ENGR. LLOYD ALDRIN T. PORNOBI

1. Objective(s):
This activity aims to introduce the microcontroller as an integral part of implementing Embedded Systems by demonstrating
how it is used to control electronic components.
2. Intended Learning Outcomes (ILOs):
After performing the laboratory activity, the students should be able to
2.1 Develop circuit that can generate output in seven-segment display
3. Discussions

For many applications, there's no need to use a more expensive liquid crystal display to display data. A simple seven-
segment display is sufficient.

If your Arduino application only needs to display numbers, consider using a seven-segment display. The severn-segment
display has seven LEDs arranged in the shape of number eight. They are easy to use and cost effective. The picture below
shows a typical seven-segment display.

Seven segment displays are of two types: common anode and common cathode. The Internal structure of both types is
nearly the same. The difference is the polarity of the LEDs and common terminal. In a common cathode seven-segment
display (the one we used in the experiments), all seven LEDs plus a dot LED have the cathodes connected to pins 3 and pin
8. To use this display, we need to connect GROUND to pin 3 and pin 8 and, connect +5V to the other pins to make the
individual segments light up. The following diagram shows the internal structure of common-cathode seven-segment display:
Common Cathode
The common anode display is the exact opposite. In a common-anode display, the positive terminal of all the eight LEDs are
connected together and then connected to pin 3 and pin 8. To turn on an individual segment, you ground one of the pins.
The following diagram shows the internal structure of the common-anode seven-segment display.

Common Anode
The seven segments are labelled a-g, with the dot being "dp," as shown in the figure below:

SSD Configuration
To display a particular number, you turn on the individual segments as shown in the table below:
4. Materials and Equipment:
1 seven segment display (common cathode)
1 Arduino MEGA 2560
1 breadboard
7 220-ohm resistors (1/4 W)
Wires
5. Procedures
Turning on the LEDs
In this circuit, the pins of seven-segment display are connected to Arduino pins 2-9, as shown in the table below. Common
pins (pin 3 and pin 8) are connected to GND and dp is left unconnected, because it is not used in this experiment .

Wiring Diagram

Code
Please write your observation in the data analysis and the screenshot of your output.

Count Down
In this tutorial, we will be interfacing a seven-segment display with Arduino mega and learn to display a count down from
nine with a delay of a second, on seven segment display.

*The same wiring diagram in the previous example.

Code
Please write your observation in the data analysis and the screenshot of your output.
6. Data Analysis:
Turning on the display
Each digit on the 7-segment display is represented by a unique combination of active segments (A-G), with digit 8
using all segments and digits like 1 and 7 using the fewest.

Count Down

To make the 7-segment display count down, each digit (9 to 0) is represented by activating specific segments
based on predefined patterns. A 1-second delay is introduced between each digit to create a visible countdown
effect.
7. Supplementary Activity:
Tasks:
1. Using the 7segment display, loop an even number starting from 0 in ascending order. After which, loop back an odd
number starting from 9 in descending order.

Screenshot of the diagram


Screenshot of the codes

int segmentA = 2;
int segmentB = 3;
int segmentC = 4;
int segmentD = 5;
int segmentE = 6;
int segmentF = 7;
int segmentG = 8;

const int digitCodes[10][7] = {


{1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 0, 0, 0, 0},
{1, 1, 0, 1, 1, 0, 1},
{1, 1, 1, 1, 0, 0, 1},
{0, 1, 1, 0, 0, 1, 1},
{1, 0, 1, 1, 0, 1, 1},
{1, 0, 1, 1, 1, 1, 1},
{1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1}
};

int segmentPins[7] = {segmentA, segmentB, segmentC, segmentD, segmentE, segmentF, segmentG};

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

void loop() {
for (int digit = 0; digit <= 8; digit += 2) {
displayDigit(digit);
delay(1000);
}

for (int digit = 9; digit >= 1; digit -= 2) {


displayDigit(digit);
delay(1000);
}
}

void displayDigit(int digit) {


for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], digitCodes[digit][i]);
}
}
8. Conclusion:
I learned how to interface a seven-segment display with an Arduino Uno, control each segment to show different
digits, and troubleshoot display issues. I also gained experience in coding dynamic visual sequences and
debugging problems.

You might also like