51單片機(jī)——靜態(tài)數(shù)碼管流動(dòng)顯示
共陰極數(shù)碼管碼表:
本文引用地址:http://m.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 無顯示
實(shí)際應(yīng)用中,定義一個(gè)數(shù)組即可:
?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);//聲明延時(shí)函數(shù)
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; //起始點(diǎn)亮全管
delay_10_ms(100); //延時(shí)1s
for(i=0;i<17;i++)
{
P0=~digit_code[i];//取反點(diǎn)亮
delay_10_ms(100);
}
}
void delay_10_ms(unsigned char t)//10ms延時(shí)程序
{
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
評(píng)論