標(biāo)題: 利用51單片機(jī)實(shí)現(xiàn)秒表功能(靜態(tài)數(shù)碼管顯示)程序 [打印本頁]

作者: 軒轅頂托    時間: 2021-7-20 09:03
標(biāo)題: 利用51單片機(jī)實(shí)現(xiàn)秒表功能(靜態(tài)數(shù)碼管顯示)程序
  1. #include <reg51.h>
  2. #define uint unsigned int
  3. #define uchar unsigned char
  4. uchar code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
  5. uchar n=0;
  6. uint i;
  7. void main()
  8. {
  9.         TMOD|=0X20;
  10.         TH1=0Xce;
  11.         TL1=0Xce;
  12.         ET1=1;
  13.         EA=1;
  14.         TR1=1;
  15.         while(1);

  16. }

  17. void Timer1() interrupt 3
  18. {


  19.         i++;
  20.         if(i==20000)
  21.         {
  22.                 i=0;
  23.                 P0=~smgduan[n++];
  24.                 if(n==10)
  25.                 {
  26.                         n=0;
  27.                 }
  28.         }
  29. }
復(fù)制代碼



作者: kscheang    時間: 2021-12-31 18:56
第04行漏了5字這個碼
uchar code smgduan[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1