/* 请自己分析语言 */
/* 0--F.共计32个数字依次在8个数码管显示*/
/* 已经在hjavr实验开发系统上跳是通过 */
#include
typedef unsigned char u08;
typedef char s08;
typedef unsigned short u16;
typedef short s16;
void delay(u08 count);
void displed(u08 data,u08 lednu);
main()
{
outp(0xff,DDRB); /* 初始化显示 */
outp(0xff, PORTB); /* */
outp(0xff,DDRD); /* 关闭蜂鸣器*/
outp(0x7f, PORTD); /* */
u08 data,led;
int deu;
while(1)
{ for(data=0,led=0;data<32;data++,led++)
{ if(data%%8==0)led =0;
displed(data,led);
for(deu=0;deu<1800;deu++)
{delay(255);}
}
}
}
void delay(u08 count)
{
u08 delayk=255;
u08 k;
for(;count !=0;count--)
{
for(;delayk!=0;delayk--)
{k++;}
}
}
void displed(u08 data,u08 lednu)
{
u08 disnu[]={0xc0 ,0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82,0xf8,
0x80 ,0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86,0x8e,
0x40 ,0x79, 0x24, 0x30, 0x19, 0x12, 0x02,0x78,
0x00 ,0x10, 0x08, 0x03, 0x46, 0x21, 0x06,0x0e};//这是led段码定义
u08 led[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//这是数码管位码定义
outp(0xff ,DDRA); //显示输出
outp(0xff ,DDRC);
outp(led[lednu],PORTA);
outp(disnu[data],PORTC);
delay(250);
}