找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

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

籃球計(jì)分牌Proteus仿真 單片機(jī)源程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
籃球計(jì)分牌的程序和仿真


單片機(jī)源程序如下:
  1. #include "reg51.h"

  2. sbit SEG1 = P1^7;
  3. sbit SEG2 = P1^6;
  4. sbit SEG3 = P1^5;
  5. sbit SEG4 = P1^4;

  6. sbit MARK1 = P3^0;
  7. sbit MARK2 = P3^1;
  8. sbit MARK3 = P3^2;

  9. unsigned char MARK;

  10. char code table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};        //段碼


  11. void delay(unsigned int t)
  12. {
  13.         while(t--);
  14. }

  15. void DigDisplay(void)
  16. {
  17.         unsigned char i;
  18.         for(i = 0;i < 4;i++)
  19.         {
  20.                 switch(i)         //位選,選擇點(diǎn)亮的數(shù)碼管,
  21.                 {
  22.                    case(0):
  23.                                 SEG4 = 0;SEG3 = 1;SEG2 = 1;SEG1 = 1;P2 = table[MARK % 10];break;
  24.                         case(1):
  25.                                 SEG4 = 1;SEG3 = 0;SEG2 = 1;SEG1 = 1;P2 = table[MARK % 100 / 10];break;
  26.                         case(2):
  27.                                 SEG4 = 1;SEG3 = 1;SEG2 = 0;SEG1 = 1;P2 = table[MARK % 1000 / 100];break;
  28.                         case(3):       
  29.                                 SEG4 = 1;SEG3 = 1;SEG2 = 1;SEG1 = 1;P2 = table[MARK % 1000 / 1000];break;
  30.                 }
  31.                 delay(100); //間隔一段時(shí)間掃描       
  32.                 P2 = 0x00;//消隱
  33.         }
  34. }

  35. void Points(void)
  36. {
  37.         if(MARK1 == 0)
  38.         {
  39.                 delay(500);
  40.                 if(MARK1 == 0)
  41.                 {
  42.                         MARK = MARK + 1;
  43.                 }
  44.                 while(!MARK1);
  45.         }
  46.        
  47.         if(MARK2 == 0)
  48.         {
  49.                 delay(500);
  50.                 if(MARK2 == 0)
  51.                 {
  52.                         MARK = MARK + 2;
  53.                 }
  54.                 while(!MARK2);
  55.         }
  56.        
  57.         if(MARK3 == 0)
  58.         {
  59.                 delay(500);
  60.                 if(MARK3 == 0)
  61.                 {
  62.                         MARK = MARK + 3;
  63.                 }
  64.                 while(!MARK3);
  65.         }
  66. }


  67. void main(void)
  68. {
  69.         while(1)
  70.         {
  71.                 Points();
  72.                 DigDisplay();
  73.         }
  74. }
復(fù)制代碼

所有資料51hei提供下載:
計(jì)分牌.zip (78.96 KB, 下載次數(shù): 27)

評(píng)分

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

查看全部評(píng)分

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

使用道具 舉報(bào)

沙發(fā)
ID:89286 發(fā)表于 2020-7-26 02:13 | 只看該作者
Thanks for sharing
回復(fù)

使用道具 舉報(bào)

板凳
ID:92643 發(fā)表于 2024-10-9 09:28 | 只看該作者
Proteus8.13版本的仿真
回復(fù)

使用道具 舉報(bào)

地板
ID:344646 發(fā)表于 2025-4-28 16:40 | 只看該作者
可以跑起來(lái)
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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