標(biāo)題:
單片機(jī)+4位一體共陽(yáng)數(shù)碼管從左到右循環(huán)顯示0~f
[打印本頁(yè)]
作者:
胡怪
時(shí)間:
2019-12-28 14:03
標(biāo)題:
單片機(jī)+4位一體共陽(yáng)數(shù)碼管從左到右循環(huán)顯示0~f
c.PNG
(84.36 KB, 下載次數(shù): 20)
下載附件
2019-12-28 14:02 上傳
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar num;
uchar m=0;
uchar code table[]= {
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e, //0~f顯示
};
uchar code address[]={0x01,0x02,0x04,0x08,};//位選
void delayms(uint);
void main( )
{
num=0;
while(1)
{
for(m=0;m<4;m++)
{
P0=table[num++];
P1=address[m];
if(num==16)num=0;
delayms(700);
}
}
}
/********************延遲****************/
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1