找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1271|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

單片機基礎(chǔ)1-9999計數(shù)器

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:1103892 發(fā)表于 2023-12-12 15:05 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
  1. #include<reg51.h>
  2. unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
  3. unsigned char code table2[]={0xf7,0xfb,0xfd,0xfe};
  4. unsigned char i,num;
  5. unsigned int count;
  6. void delay(int);
  7. main()
  8. {
  9.   while(1)
  10.   {       
  11.         {if(count==9999)count=0;}
  12.         count++;
  13.         for(num=0;num<200;num++)
  14.         {P0=0x00;
  15.          P2=table2[0];
  16.          P0=table1[((count%1000)%100)%10];
  17.          delay(1);

  18.          P0=0x00;
  19.          P2=table2[1];
  20.          P0=table1[((count%1000)%100)/10];
  21.          delay(1);

  22.          P0=0x00;
  23.          P2=table2[2];         
  24.          P0=table1[(count%1000)/100];
  25.          delay(1);

  26.          P0=0x00;
  27.          P2=table2[3];
  28.          P0=table1[count/1000];
  29.          delay(1);
  30.          }       
  31.   }       
  32. }
  33. void delay(int x)
  34. {
  35.   int i,j;
  36.   for(i=0;i<x;i++)
  37.      for(j=1;j<=150;j++);
  38. }
復(fù)制代碼

1-9999計數(shù)器.zip (66.42 KB, 下載次數(shù): 19)

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表