AT89C51单片机实现4位数码管显示学号后四位,谢谢

AT89C51单片机实现4位数码管显示学号后四位,谢谢麻烦大神帮忙写个Keil C语言程序,要是能有proteus绘制的图就更完美了

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
//共阴数码管七段码

uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77};
uchar code table2[]={5,4,3,2};//这就是学号的后4位,自行修改
void display()//4位显示子程序
{
P0=~(table[ table2[0]]);

wei1=0;
Delay1ms(2);
wei1=1;

P0=~(0x80|table[ table2[1]]);
wei2=0;
Delay1ms(2);
wei2=1;

P0=~(table[ table2[2]]);
wei3=0;
Delay1ms(2);
wei3=1;

P0=~(table[ table2[3]);
wei4=0;
Delay1ms(2);
wei4=1;
}
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void main(void )//主程序
{
while(1)
{
display();
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-12-21
wei4=0;上面少了个中括号
相似回答