unsigned int count;
short int ds1,ds2,ds3,ds4,i;
short int mask(short int get)
{
switch (get)
{
case 0: return 0xc0;
case 1: return 0xf9;
case 2: return 0xa4;
case 3: return 0xb0;
case 4: return 0x99;
case 5: return 0x92;
case 6: return 0x82;
case 7: return 0xf8;
case 8: return 0x80;
case 9: return 0x98;
}
}
void interrupt()
{
if(rb0_bit)
{
intcon.intf=0;
delay_ms(10);
count++;
if(count>9999) count=0;
}
}
void main()
{
cmcon=0x07;
adcon1=0x06;
option_reg.intedg=1;
INTCON.GIE = 1;
INTCON.INTE = 1;
trisd=0x00;
trisb=0x01;
trisc=0x10;
portc=0xff;
portd=0xff;
count=1234;
do
{
ds1=(count%10);
ds1= mask(ds1);
ds2=(count/10)%10;
ds2= mask(ds2);
ds3=(count/100)%10;
ds3= mask(ds3);
ds4=(count/1000);
ds4= mask(ds4);
for(i=0;i<50;i++)
{
portd=(ds4);
portc.f0=0;
portc.f1=1;
portc.f2=1;
portc.f3=1;
delay_ms(1);
portd=(ds3);
portc.f0=1;
portc.f1=0;
portc.f2=1;
portc.f3=1;
delay_ms(1);
portd=(ds2);
portc.f0=1;
portc.f1=1;
portc.f2=0;
portc.f3=1;
delay_ms(1);
portd=(ds1);
portc.f0=1;
portc.f1=1;
portc.f2=1;
portc.f3=0;
delay_ms(1);
}
}while(1);
}