#include"reg52.h"
#defineu16unsignedint
#defineu8unsignedchar
sbitCLK=P2^0;
sbitDAT=P2^1;
u8codetab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};//0-9
全灭
//
函数声明
voidSend_Byte(u8byte);
voidDelay_ms(u16z);
voidDisplay(u16number);
//
主函数
voidmain()
{
while(1)
{
Display(1111);
Delay_ms(3000);
//
Display(2222);
//
Delay_ms(3000);
}
}
//
数码管显示函数
voidDisplay(u16number)
{
u8qian,bai,shi,ge;
qian=number/1000;
Send_Byte(qian);
Delay_ms(5);
bai=number%1000/100;
Send_Byte(bai);
Delay_ms(5);
shi=number%100/10;
Send_Byte(shi);
Delay_ms(5);
ge=number%1000;
Send_Byte(ge);
Delay_ms(5);
}