Monday, 19 October 2015

PIC16F877A SEVEN SEGMENT MULTIPLEXING


#include<pic.h>
#include<htc.h>
#define _PIC16F877A_H
#define x PORTCbits.RC0
#define y PORTCbits.RC1
#define z PORTCbits.RC2
//__CONFIG(PWRTE_ON & FOSC_HS & LVP_OFF & WDTE_OFF);
void delay(int r)
{
while(r--);
}
void main()
{
TRISB=0X00;
    TRISC=0X00;
int i,b,c=0,d=0,f=0;
int a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};
while(1)
{
for(i=0;i<10;i++)
{
while(!(f==8))
{f++;
       x=1;
       y=1;
       z=0;
PORTB=a[i];
delay(150);

       y=0;
      x=1;
      z=1;
     PORTB=a[c];
delay(150);

      y=1;
      x=0;
      z=1;
     PORTB=a[d];
delay(150);

}f=0;
}

c++;
if(c>9)
{
 d++;
c=0;
}
}
}




No comments:

Post a Comment