久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3071|回復: 2
打印 上一主題 下一主題
收起左側

BASCOM-8051寫的單片機開發板4位led時鐘仿真附帶串口輸出程序

[復制鏈接]
跳轉到指定樓層
樓主
用BASCOM-8051寫的4位led時鐘,帶串口輸出。附源碼,hex文件,protues仿真文件。
代碼較粗燥,只是為了驗證軟硬件功能。
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. $crystal = 11059000
  2. $baud = 9600

  3. Dim Ct As Byte
  4. Dim H As Byte
  5. Dim H1 As Byte
  6. Dim H2 As Byte
  7. Dim M As Byte

  8. Dim M1 As Byte
  9. Dim M2 As Byte

  10. Dim S As Byte

  11. Dim S1 As Byte
  12. Dim S2 As Byte
  13. Dim Led0 As Bit                                               'LED is a Bit variable since it will turn on and
  14. Dim Led1 As Bit
  15. Dim Point As Byte
  16. Dim K As Byte


  17. Dim A(10) As Byte
  18. A(1) = Not &H06
  19. A(2) = Not &H5B
  20. A(3) = Not &H4F
  21. A(4) = Not &H66
  22. A(5) = Not &H6D
  23. A(6) = Not &H7D
  24. A(7) = Not &H07
  25. A(8) = Not &H7F
  26. A(9) = Not &H6F
  27. A(10) = Not &H3F


  28. Config Timer0 = Timer , Gate = Internal , Mode = 1
  29. 'Timer0 = counter : timer0 operates as a counter
  30. 'Gate = Internal  : no external gate control
  31. 'Mode = 2         : 8-bit auto reload (default)
  32. 'Mode = 1         : 16-bit reload
  33. On Timer0 Timer_0_int
  34. Load Timer0 , 0                                               'when the timer reaches 100 an interrupt will occur
  35. Enable Interrupts                                             'enable the use of interrupts
  36. Enable Timer0                                                 'enable the timer


  37. Rem Setting Of Priority
  38. Priority Set Timer0                                           'highest priority
  39. Start Timer0



  40. Led0 = 1
  41. Led1 = 0

  42. P2 = &HFF


  43. Do


  44. K = Inkey()
  45. If K = 48 Then
  46.    M = M + 1
  47.    If M = 60 Then
  48.       M = 0
  49.    End If
  50. Elseif K = 49 Then
  51.    M = M - 1
  52.    If M = 255 Then
  53.       M = 59
  54.    End If
  55. End If

  56. P2.0 = 0
  57. P0 = A(m1)
  58. Waitms 2
  59. P2.0 = 1
  60. Waitms 3

  61. P2.1 = 0
  62. If Point = 1 Then
  63.    P0 = A(m2) + &H80
  64. Else
  65.    P0 = A(m2)
  66. End If
  67. Waitms 2
  68. P2.1 = 1
  69. Waitms 3

  70. P2.2 = 0
  71. P0 = A(s1)
  72. Waitms 2
  73. P2.2 = 1
  74. Waitms 3

  75. P2.3 = 0
  76. P0 = A(s2)
  77. Waitms 2
  78. P2.3 = 1
  79. Waitms 3


  80. Loop
  81. End


  82.   Rem The Interrupt Handler For The Timer0 Interrupt
  83. Timer_0_int:
  84. If Ct = 13 Then
  85.      Ct = 0

  86.      P1.1 = Led1
  87.      P1.0 = Led0

  88.      Led0 = Not Led0
  89.      Led1 = Not Led1                                          'invert LED value


  90.      H1 = H / 10
  91.      H2 = H Mod 10
  92.      M1 = M / 10

  93.      M2 = M Mod 10

  94.      S1 = S / 10

  95.      S2 = S Mod 10
  96.      Point = S Mod 2

  97.      Print "Time is:" ; H1 ; H2 ; ":" ; M1 ; M2 ; ":" ; S1 ; S2       '; (Second / 10) ;
  98.      If M1 = 0 Then
  99.       M1 = 10
  100.      End If
  101.      If M2 = 0 Then
  102.       M2 = 10
  103.      End If
  104.      If S1 = 0 Then
  105.       S1 = 10
  106.      End If
  107.      If S2 = 0 Then
  108.       S2 = 10
  109.      End If
  110.      S = S + 1
  111.      If S = 60 Then
  112.            S = 0
  113.            M = M + 1

  114.            If M = 60 Then
  115.               M = 0
  116.               H = H + 1
  117.               If H = 24 Then
  118.                  H = 0
  119.               End If
  120.            End If
  121.      End If
  122. Else
  123.    Incr Ct
  124. End If
  125. Return
復制代碼

所有資料51hei提供下載:
QXmini51.zip (612.65 KB, 下載次數: 8)


評分

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

查看全部評分

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

使用道具 舉報

沙發
ID:806933 發表于 2020-7-22 22:52 | 只看該作者
hotpet 你好,看到你發的BASCOM 貼我很高興,希望能加你 QQ
回復

使用道具 舉報

板凳
ID:806933 發表于 2020-7-22 22:52 | 只看該作者
hotpet 你好,看到你發的 BASCOM 貼很想和你聯系一下 請加我QQ 976086284
回復

使用道具 舉報

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

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 激情欧美日韩一区二区 | 欧美午夜在线 | 91国内视频在线 | 久久一视频 | 91精品亚洲 | 黄色大片免费观看 | 中文字幕日韩一区二区 | 中文成人在线 | 国产成人精品a视频一区www | 国产精品福利在线观看 | 日韩欧美国产精品 | av电影一区 | 欧美午夜视频 | 久久久久久国产精品免费免费狐狸 | 国产精品久久久久久吹潮 | 男女黄网站 | 欧美午夜在线 | 久久精品一区二区视频 | 男女国产视频 | 亚洲免费视频在线观看 | av中文字幕在线 | 中文字幕不卡在线观看 | 欧美精选一区二区 | 日韩成人在线观看 | 在线国产视频观看 | 超碰人人做| 久久久久久久国产 | 成人欧美一区二区三区视频xxx | 播放一级毛片 | 国产偷录视频叫床高潮对白 | 亚洲国产欧美在线人成 | 情侣av| 久久久九九 | 中文字幕av第一页 | 欧美日韩中文在线 | 欧美国产精品久久久 | 日韩av免费在线观看 | 免费观看黄a一级视频 | 亚洲v日韩v综合v精品v | 特级丰满少妇一级aaaa爱毛片 | 欧美一区二不卡视频 |