0% found this document useful (0 votes)
25 views

MP Lab Report # 2

The document describes an experiment to interface a seven segment display with a PIC18F452 microcontroller. The objectives are to implement an up/down counter from 0-9 and from 00-99. Students are provided the hardware components, introduction on how seven segment displays work, and procedures to write code for a 0-9 and 9-0 counter. The code is tested in Proteus and on real hardware. The conclusion states the lab helped learn seven segment display code and applying it to hardware.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

MP Lab Report # 2

The document describes an experiment to interface a seven segment display with a PIC18F452 microcontroller. The objectives are to implement an up/down counter from 0-9 and from 00-99. Students are provided the hardware components, introduction on how seven segment displays work, and procedures to write code for a 0-9 and 9-0 counter. The code is tested in Proteus and on real hardware. The conclusion states the lab helped learn seven segment display code and applying it to hardware.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER


ENGINEERING
EXPERIMENT: 02

Lab Title: Interface Seven Segment Display With PIC18F452

Student Name: ABDUL MOEED, HASSAN ZEB, UMAIR-UL-HASSAN

Reg. No: 190378, 190570, 190538

Objective: To get recognized with the Interface Seven Segment Display with PIC18F452

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:


Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: Signature:
Lab 2
Interface Seven Segment Display
With PIC18F452

Objectives:
 Implementing up/down counter from 0-9
 Implementing up/down counter from 00-99
Hardware:
 PIC18F452 microcontroller
 Seven segment displays (SSDs) Common Anode
 Resistances

Introduction:
For the seven segment display you can use the LT-541 or LSD5061-11 chip. Each of the
segments of the display is connected to a pin on the PIC18f452 (the schematic shows how to do
this). In order to light up a segment on the pin must be set to 0V. To turn a segment off the
corresponding pin must be set to 5V. This is simply done by setting the pins on the PIC18f452 to
'1' or '0'. SSD is available in two types Common anode and Common cathode, but common
anode display is most suitable for interfacing with PIC18f452 since PIC18f452 can sink current
better than sourcing it. In common anode the common terminal is tied to +5V through a
resistance and 0V should be provided to the segment you need to glow or turn on.
Procedure:
Open MikroC and make a new project then click on “7” on main toolbar as shown below.

A window will appear as shown below.

Here on this window you can click on red led to turn them off or on. Now you can get the
decimmle values which you must have to send to I/O port to write your required numeric on
SSD. Here some examples are given

By noting the decimle or hex value for common anode shown above you can easily write your
required code.
Lab Task#1:
Write a code to make a counter from 0 to 9 for a common anode SSD. Show your output in
proteus and on hardware.

CODE:
void main() {

unsigned short int ssd1[10]={192,249,164,176,153,146,130,248,128,144}; //defining an array

int i;

Trisb=0; //Define PORTB as output

While(1) //Infinite loop

{ for(i=0;i<10;i++) //Simple “for” loop from 0 to 10

{ Latb=ssd1[i]; //To get the specific data from array (as ssd1[0]=192, ssd1[1]=249…)and send it to port B

delay_ms(200); //getting delay of 200ms

}}}

Schematic:
Hardware
Task 2:

Write a code to make a counter from 9 to 0 for a common anode SSD. Show your output in
proteus and on hardware.

Code:
void main() {

unsigned short int ssd1[10]={192,249,164,176,153,146,130,248,128,144}; //defining an array

int i;

Trisb=0; //Define PORTB as output

While(1) //Infinite loop

{ for(i=10;i>0;i--) //Simple “for” loop from 10 to 0

{ Latb=ssd1[i]; //To get the specific data from array (as ssd1[0]=192, ssd1[1]=249…)and send it to port B

delay_ms(200); //getting delay of 200ms

}}}

Schematic:
Hardware:

Conclusion:
In this lab we learned the code of seven segment display and applied it on the hardware through
burning the code by smart-pro 500u. We demonstrated the display of numbers on the seven
segment display both in ascending and descending order.

You might also like