BCD譯碼芯片4511數(shù)碼管顯示
#include
unsigned char code dis_buf[]={2,0,1,0,1,1,2,8};
unsigned char code dis_bitcode[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE};
unsigned char code dis_code[]= {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09};
/*************延時子程序*******************************/
void delay_ms(unsigned int x)//最小1毫秒
{
unsigned char j;
while(x--)
{
for(j=0;j<125;j++)
{;}
}
}
void main()
{
while(1)
{
P1=dis_code[dis_buf[0]];
P2=dis_bitcode[7];
delay_ms(70);
P1=dis_code[dis_buf[1]];
P2=dis_bitcode[6];
delay_ms(70);
P1=dis_code[dis_buf[2]];
P2=dis_bitcode[5];
delay_ms(70);
P1=dis_code[dis_buf[3]];
P2=dis_bitcode[4];
delay_ms(70);
P1=dis_code[dis_buf[4]];
P2=dis_bitcode[3];
delay_ms(70);
P1=dis_code[dis_buf[5]];
P2=dis_bitcode[2];
delay_ms(70);
P1=dis_code[dis_buf[6]];
P2=dis_bitcode[1];
delay_ms(70);
P1=dis_code[dis_buf[7]];
P2=dis_bitcode[0];
delay_ms(70);
}
}
仿真電路:
評論