dolphinlabs
...
Doplhin labs
News

PIC18F4520-7 Segment Display Interfacing


·         Program Statement: Interfacing of seven segment to PIC 18F4520

Connections:  PORT RC7= disp1 

                         PORT C= data lines of seven segment

Hardware connections for PIC184520 Board:

1.      Give supply to the Board with the help of adapter.

2.      Connect +5V pin of PIC controller to +5v supply and GND pin of controller to GND pin of supply.

3.      Connect disp1 pin of seven segment to PORT RC7.

4.      Connect data lines of seven segment to PORT C.

5.      Connect +5V COMMON ANODE pin of seven segment to +5V supply pin.

 

Circuit Diagram:

 

 

 

 

 

 

 

Program code:

#include<P18F4520.h>

#define disp1 PORTCbits.RC7                         //define RC7 as disp1

 void delay();

 int i;

int a[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //Hex values of numbers 0-9 for          //common anode display

 

void main()

 {

TRISC=0x00;                                                      //make PORTC as output port

while(1)

 {            

                                for(i=0;i<=9;i++)

                                {

                                disp1=1;                                                //make disp1 high

                                PORTC=a[i];                        //transfer hex values to port C

                                delay();                                  //call delay

                                }

 }

 }

void delay()

 {

                int i,j;

                for(i=0;i<255;i++)

                for(j=0;j<255;j++);

 }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

visa card master card maestro card
Maverick IT Industries Pvt. Ltd.