#include
#define uchar unsigned char
void display(uchar number,uchar position);
void delay(uchar time)
{
uchar b;
for(;time>0;time--)
for(b=200;b>0;b--);
}
void main(void)
{
DDRA=0xff;
PORTA=0xff;
while(1)
{
display(5,1);
delay(5);
}
}
void display(unsigned char number,unsigned char position)//êy??1ü?y?ˉ3ìDò
{
PORTA="0xff";
switch(position)
{
case 1:{PORTA=PINA&0xf8;break;}
case 2:{PORTA=PINA&0xf9;break;}
case 3:{PORTA=PINA&0Xfa;break;}
case 4:{PORTA=PINA&0Xfb;break;}
case 5:{PORTA=PINA&0Xfc;break;}
case 6:{PORTA=PINA&0Xfd;break;}
case 7:{PORTA=PINA&0Xfe;break;}
case 8:{PORTA=PINA&0Xff;break;}
}
switch(number)
{
case 0:{PORTA=PINA&0x87;break;} //0
case 1:{PORTA=PINA&0x8f;break;} //1
case 2:{PORTA=PINA&0x97;break;} //2
case 3:{PORTA=PINA&0x9f;break;} //3
case 4:{PORTA=PINA&0xa7;break;} //4
case 5:{PORTA=PINA&0xaf;break;} //5
case 6:{PORTA=PINA&0xb7;break;} //6
case 7:{PORTA=PINA&0xbf;break;} //7
case 8:{PORTA=PINA&0xc7;break;} //8
case 9:{PORTA=PINA&0xcf;break;} //9
default:{PORTA=PINA&0xff;break;} //null
}
DDRA=0xff;
}
文章评论(0条评论)
登录后参与讨论