#define Sel_one RB1
#define Sel_two RB2
#define Sel_three RB3
#define Sel_four RB4
const unsigned char led[11]={0xc0,0xf9,0xa4,0xB0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf};
unsigned int average,sum1,rem2,angel1,angel2,int1,int2,int3;
unsigned char delay(unsigned int k) //k ms延时
{
unsigned char j;
for(;k!=0;k--)
for(j=106;j!=0;j--);
return(1);
}
void initIO()
{
PORTA=0x0f;
PORTC=0x00;
PORTE=0x07;
ADCON1=0x07;
TRISA=0x00;
TRISB=0x00;
TRISC=0xd5;
TRISE=0x00;
TRISD=0x00;
PORTA=0x1f;
PORTC=0x28;
PORTE=0x07;
PORTD=0x00;
}
void display()
{
unsigned int j;
Sel_one=1;
PORTD=0xff;
for(j=0;j<=200;j++);
Sel_one=0;
Sel_two=1;
PORTD=led[int1];
for(j=0;j<=200;j++);
Sel_two=0;
Sel_three=1;//
PORTD=led[int2];//&0x7f;
for(j=0;j<=200;j++);
Sel_three=0;
Sel_four=1;
PORTD=led[int3];
for(j=0;j<=200;j++);
Sel_four=0;
}
main()
{
initIO();
while(1)
{
if(int3==9)
{
int3=0;
int2++;
}
if(int2==9)
{
int2=0;
int1++;
}
display();
int3++;
if(int1==9)int1=0;
delay(100);
}
}
文章评论(0条评论)
登录后参与讨论