|
#include <pic.h>//*00-99数的递增*//
const unsigned char table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};
volatile unsigned char data,datab;
unsigned char k=0;
unsigned int i;
unsigned int j;
void initport()
{
TRISA=0x04;
TRISB=0x00;
}
void delay()
{
for(i=0;i=6553;i++) //这里控制刷新时间
asm("clewdt");
}
void LED_1()
{
RA0=0; //个位数数值扫描显示.
PORTB=table[k%10];
RA0=1;
}
void LED_2()
{
RA1=0; //十位数数值扫描显示.
PORTB =table[k/10];
RA1=1;
}
void main(void)
{
initport();
PORTA=0;
PORTB=0;
while(1)
{
for(j=0;j<1000;j++) //这里控制递增时间
{LED_1();
delay(); LED_2();
delay();
}
if(k<=99) k++;
else k=0;
}
} |
|