国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee

 找回密碼
 注冊
搜索

基于51單片機的跑馬燈Proteus仿真和程序源碼

[復制鏈接]
樓主
eng 發表于 2021-6-28 00:55:39 | 只看該作者 |只看大圖 |倒序瀏覽 |閱讀模式
基于51單片機的跑馬燈Proteus仿真和程序源碼 1.gif
部分源碼如下:完整源碼見附件
程序.rar (275.77 KB, 售價: 1 E幣)
仿真.zip (27.74 KB, 售價: 1 E幣)
  1. #include <REG52.H>
  2. #include "SoundPlay.h"

  3. unsigned char RunMode;

  4. //**********************************System Fuction*************************************************
  5. void Delay1ms(unsigned int count)
  6. {
  7.         unsigned int i,j;
  8.         for(i=0;i<count;i++)
  9.         for(j=0;j<120;j++);
  10. }

  11. unsigned char code LEDDisplayCode[] = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,        //0~7
  12.                                                           0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0xFF};

  13. void Display(unsigned char Value)
  14. {
  15.         P3 = LEDDisplayCode[Value];
  16. }

  17. void LEDFlash(unsigned char Count)
  18. {
  19.         unsigned char i;
  20.         bit Flag;
  21.         for(i = 0; i<Count;i++)
  22.         {
  23.                 Flag = !Flag;
  24.                 if(Flag)
  25.                         Display(RunMode);
  26.                 else
  27.                         Display(0x10);
  28.                 Delay1ms(100);
  29.         }
  30.         Display(RunMode);
  31. }

  32. unsigned char GetKey(void)
  33. {
  34.         unsigned char KeyTemp,CheckValue,Key = 0x00;
  35.         CheckValue = P2&0x32;
  36.         if(CheckValue==0x32)
  37.                 return 0x00;
  38.         
  39.         Delay1ms(10);
  40.         KeyTemp = P2&0x32;
  41.         if(KeyTemp==CheckValue)
  42.                 return 0x00;

  43.         if(!(CheckValue&0x02))
  44.                 Key|=0x01;
  45.         if(!(CheckValue&0x10))
  46.                 Key|=0x02;
  47.         if(!(CheckValue&0x20))
  48.                 Key|=0x04;
  49.         return Key;
  50. }

  51. unsigned int Timer0Count,SystemSpeed,SystemSpeedIndex;
  52. void InitialTimer2(void)
  53. {
  54.         T2CON  = 0x00;                        //16 Bit Auto-Reload Mode
  55.          TH2 = RCAP2H = 0xFC;          //重裝值,初始值        TL2 = RCAP2L = 0x18;
  56.         ET2=1;                                        //定時器 2 中斷允許
  57.         TR2 = 1;                                //定時器 2 啟動
  58.         EA=1;
  59. }

  60. unsigned int code SpeedCode[]={   1,   2,   3,   5,   8,  10,  14,  17,  20,  30,
  61.                                                              40,  50,  60,  70,  80,  90, 100, 120, 140, 160,
  62.                            
復制代碼


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

本版積分規則

手機版|小黑屋|ELEOK |網站地圖

GMT+8, 2026-5-26 06:06

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表