You are on page 1of 4

EXPERIMENT-6

AIM: To interface a 7-segment display with pic uC and display numbers 0


to 9 on it.

SOFTWARE USED: MPLAB


THEORY:
7 Segment Display has seven segments in it and each segment has one
LED inside it to display the numbers by lighting up the corresponding
segments. Like if you want the 7-segment to display the number "5" then
you need to glow segment a,f,g,c, and d by making their corresponding
pins high. There are two types of 7-segment displays: Common Cathode
and Common Anode.

Common Cathode: In this type of segments all the cathode terminals are
made common and tied to GND. Thus, the segments a to g needs a logic
High signal(5v) in order to glow.

Common Anode: In this type of segments all the anodes terminals are
made common and tied to VCC(5v). Thus, the segments a to g needs a
logic LOW signal (GND) in order to glow.

FIG. 6.1 AND FIG.


6.2

CODE:

#include<htc.h>
#define _XTAL_FREQ 8000000
void main()
{
TRISB=0X00;
PORTB=0X00;
while(1)
{
PORTB=0X3F;
__delay_ms(100);
PORTB=0X06;
__delay_ms(100);
PORTB=0X5B;
__delay_ms(100);
PORTB=0X4F;
__delay_ms(100);
PORTB=0X66;
__delay_ms(100);
PORTB=0X6D;
__delay_ms(100);
PORTB=0X7D;
__delay_ms(100);
PORTB=0X07;
__delay_ms(100);
PORTB=0X7F;
__delay_ms(100);
PORTB=0X6F;
__delay_ms(100);
}
}

OUTPUT:

You might also like