51單片機——靜態(tài)數碼管流動顯示
共陰極數碼管碼表:
本文引用地址:http://butianyuan.cn/article/201611/321837.htm0x3f , 0x06 , 0x5b , 0x4f ,0x66 , 0x6d ,
0 1 2 3 4 5
0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c ,
6 7 8 9 A B
0x39 , 0x5e , 0x79 , 0x71 , 0x00
C D E F 無顯示
實際應用中,定義一個數組即可:
?unsigned charcodeDIG_CODE[17]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71,0x00};
?
#include?< reg51.h >
void delay_10_ms(unsigned char t);//聲明延時函數
unsigned char code digit_code[17]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00};
void main(void)
{
unsigned char i;
P0=0x00; //起始點亮全管
delay_10_ms(100); //延時1s
for(i=0;i<17;i++)
{
P0=~digit_code[i];//取反點亮
delay_10_ms(100);
}
}
void delay_10_ms(unsigned char t)//10ms延時程序
{
unsigned char i,j;
for(;t>0;t--)
for(i=38;i>0;i--)
for(j=130;j>0;j--);
}
參考鏈接:
http://www.21ic.com/jichuzhishi/mcu/program/2013-05-22/182240_2.html?
http://www.cnblogs.com/zhliao/archive/2012/05/22/2513886.html
評論