標(biāo)題:
單片機(jī)0-99計(jì)秒器程序
[打印本頁]
作者:
0.0.
時(shí)間:
2019-6-24 18:52
標(biāo)題:
單片機(jī)0-99計(jì)秒器程序
這個(gè)程序非常簡單,用這個(gè)來發(fā)帖試試,如果有錯(cuò)誤的話請指正
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code segcode []={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90} ; //定義段碼
uchar code bitcode []={0xf7,0xfb};//定義位碼
uchar dispbuf[2];
uint count;
void DelayMs (uint n)
{
uchar j;
while (n--)
{
for (j=0;j<113;j++);
}
} //延時(shí)0.5秒
void numtobuf(void)
{
dispbuf[1]=count/10%10;
dispbuf[0]=count%10;
}
void buftoseg(void)
{
uchar i;
for(i=0;i<2;i++)
{
P0=segcode[dispbuf[i]];
P2=bitcode[i];
DelayMs(1);
}
}
void main (void)
{
uint k;
while(1)
{
if(++k==220)
{
k=0;
if(++count==100)count=0;
}
numtobuf();
buftoseg();
}
}
復(fù)制代碼
0-99計(jì)秒器.zip
2019-6-24 18:51 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
18.59 KB, 下載次數(shù): 3, 下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1