用C51编程实现8个数码管稳定点亮,实现显示12345678

2024-11-10 17:59:42
推荐回答(1个)
回答1:

#define Led_Port P0
#define Led_Cont_Port P1

void delay()
{
unsigned char i,j;
for(i=0;i<5;i++)
{
for(j=0;j<200;j++)
{;}
}
}
viod main()
{
while(1)
{
Led_Cont_Port =0xFF;
Led_Port=0xFF;

Led_Port =Led_Table[1];
Led_Cont_Port =0xFE;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[2];
Led_Cont_Port =0xFD;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[3];
Led_Cont_Port =0xFB;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[4];
Led_Cont_Port =0xF7;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[5];
Led_Cont_Port =0xEF;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[6];
Led_Cont_Port =0xDF;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[7];
Led_Cont_Port =0xBF;
delay();

Led_Cont_Port =0xFF;
Led_Port =Led_Table[8];
Led_Cont_Port =0x7F;
delay();
}
}