void main()
{
#define data1 PORTC.F1
#define clk PORTC.F0
#define seg1 PORTC.F3
#define seg2 PORTC.F4
#define seg3 PORTC.F5
unsigned char aray1[10]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfc,0x87,0xff,0xe7};
void shift(unsigned char value)
{
unsigned char temp1,i;
temp1=value;
for(i=0;i<8;i++)
{
clk=0;
data1=temp1/128;
clk=1;
temp1=temp1<<1;
}
}
void display(unsigned int value)
{ unsigned char j,k,l,m;
k=value%10;
value=value/10;
l=value%10;
value=value/10;
m=value%10;
for(j=0;j<50;j++)
{
shift(aray1[m]);
seg1=1;
seg2=0;
seg3=0;
Delay_ms(1);
seg1=0;
seg2=0;
seg3=0;
shift(aray1[l]);
seg1=0;
seg2=1;
seg3=0;
Delay_ms(1);
seg1=0;
seg2=0;
seg3=0;
shift(aray1[k]);
seg1=0;
seg2=0;
seg3=1;
Delay_ms(1);
seg1=0;
seg2=0;
seg3=0;
}
}
void main()
{ unsigned int temp=0,count=0;
unsigned char r;
TRISA=0x03;
CMCON=0x00;
OPTION_REG|=0x80;
WPUA=0xff;
TRISC=0x00;
while(1)
{ ADCON0=0x80;
ADCON1=0x70;
ANSEL=0x03;
Delay_ms(1);
for(r=0;r<10;r++)
{
ADCON0.ADON=1;
Delay_ms(1);
ADCON0|=(1<<GO);
while(!(ADCON0&(1<<GO)));
Delay_ms(1);
temp=((ADRESL)|(ADRESH<<8));
count=count+temp;
}
display(count/10);
count=0;
}
}