Experiment No 4
Experiment No 4
04
Introduction
The main aim of this lab is to interface seven segment display with microcontroller (Arduino)
and observe their functionalities. The display counts from 0-9 and resets itself to zero.
Objectives
Understand the functionality of Seven Segment Display
Understand the code of Arduino and its working.
Outcomes
By the end of this experiment, student will have basic understanding of how to interface the
seven segment display with microcontroller and will also understand the working principle of
seven segment display.
Theory Overview
Seven segment displays are the output display devices that provide a way to display information
in the form of image or text. For displaying the images or text in a proper manner, some types
of displays can show only alphanumeric characters and digits. A seven segment display got its
name from the very fact that it got seven illuminating segments. Each of these segments has a
LED (Light Emitting Diode), hence the lighting. The LEDs are so fabricated that lighting of
each LED is contained to its own segment as shown in figure 4.1
Below truth table gives the information required for driving the common anode seven segments.
Above truth table shows the data to be applied to the seven segments to display the digits. In
order to display digit‘0’ on seven segment , segments a , b , c , d , e and f are applied with logic
high and segment g is applied with logic low.
To test the 7-segment use your Digital multi-meter and set it in the ohmmeter, connect
the red probe to pin 3 or 8 (com pins) of the 7-segment and run the black probe on pins
1,2,4,5,6,7,9,10 (a,b,c,d,e,f,g,dp).When the meter is set to ohmmeter it acts as a voltage
source as the positive terminal is the positive of the source and the negative terminal is
the negative of the source.
LAB Exercise 1
Make a project to display a number 0 to 9 on seven segment display by using Arduino
microcontroller also create a circuit diagram and develop a code.
Required Hardware
Arduino board
Adjustable DC Power Supply
HDSP5503 seven segment display (common cathode)
Resistors 220Ω
Digital Multimeter
Breadboard
Probes
Wires
Circuit Diagram
We need to turn the LEDs of segments “A, B, C, D, E F”, so we need to power PIN0,
PIN1, PIN2, PIN3, PIN4 and PIN5. So every time we need a “0”, we need to power all
the pins mentioned. Now, if we want “1” on display as shown in figure 4.7.2
void loop()
switch (COUNT)
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, LOW);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;
digitalWrite(segG, HIGH);
break;
break;
if (COUNT<10)
COUNT++;
if (COUNT==10)
{
COUNT=0;// if count integer value is equal to 10, reset it to zero.
delay(1000);
}
}
LAB Exercise 2
Make a project to display the numbers from 00 to 99 on two Seven-Segment. Create a circuit
diagram an develop code in Arduino IDE.
Required Hardware
Arduino Uno - 1
Programmer Cable - 1
Seven-Segment Display - 2
Bread Board - 1
Male-Male Jumper Wires
Since this is for Common Anode SSD, the LED glows when it is LOW/0.
If you are using a Common Cathode SSD, attach pins 3 and 8 to ground and then the LEDs glow
when attached to HIGH/1.
Do not let 5 V pass through any of your LEDs, You must use resistors.
Table 4.5 connection table of Arduino uno with seven segment display
Arduino Pin SSD 1 Arduino Pin SSD 2
0 7 7 7
1 6 8 6
2 4 9 4
3 2 10 2
4 1 11 1
5 9 12 9
6 10 13 10
void setup()
{
for (int
i = 0; i <= 13; i++)
pinMode(i, OUTPUT); //Set all pins from 0 to 13 as OUTPUT
}
//The line below is the array containing all the binary numbers
for the digits on a SSD from 0 to 9
void loop()
{
{
display_tens(tens);
}
}
//pin1 is just used to deal with pins of the 1st SSD which
displays the tens digit
display_ones(ones);
delay(300);
//I have given a delay of 300 milliseconds. You can put your
own Time!!
}
}
//pin2 is just used to deal with pins of the 2nd SSD which
desplays the ones digit
bitRead()
Description The bitRead command returns the bit value of the bit index
requested
Precautions
Before you start to mess with a computer there are basic guidelines to be aware of, such as turn
the power off and watch out for static electricity. The three kind of activity that requires
touching the Arduino
Question 1
Solve the LAB Exercise 1
Develop the code
Sketch the circuit diagram
Attached the hardware running picture in color
Question 2
Solve the LAB Exercise 2
Develop the code
Sketch the circuit diagram
Attached the hardware running picture in color
LAB Assessment
Date Signature