標題:
單片機基礎(chǔ)1-9999計數(shù)器
[打印本頁]
作者:
張中瓊
時間:
2023-12-12 15:05
標題:
單片機基礎(chǔ)1-9999計數(shù)器
1-9999.png
(52.87 KB, 下載次數(shù): 35)
下載附件
2023-12-12 15:04 上傳
#include<reg51.h>
unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
unsigned char code table2[]={0xf7,0xfb,0xfd,0xfe};
unsigned char i,num;
unsigned int count;
void delay(int);
main()
{
while(1)
{
{if(count==9999)count=0;}
count++;
for(num=0;num<200;num++)
{P0=0x00;
P2=table2[0];
P0=table1[((count%1000)%100)%10];
delay(1);
P0=0x00;
P2=table2[1];
P0=table1[((count%1000)%100)/10];
delay(1);
P0=0x00;
P2=table2[2];
P0=table1[(count%1000)/100];
delay(1);
P0=0x00;
P2=table2[3];
P0=table1[count/1000];
delay(1);
}
}
}
void delay(int x)
{
int i,j;
for(i=0;i<x;i++)
for(j=1;j<=150;j++);
}
復(fù)制代碼
1-9999計數(shù)器.zip
(66.42 KB, 下載次數(shù): 19)
2023-12-12 15:04 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1