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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

單片機60s計時器程序,自動計時,無返回 求幫助

[復制鏈接]
跳轉到指定樓層
樓主
60s計時器,自動計時,無返回

單片機源程序如下:
  1. //0-59自動計數器
  2. //跳線設置:默認
  3. #include<reg51.h>
  4. unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  5. unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  6. unsigned char timer=0;
  7. unsigned char second;
  8. main()
  9. {
  10.                 TMOD = 0x01;        
  11.                 EA=1;            //總中斷打開
  12.                 ET0=1;           //定時器中斷打開
  13.                 second=0;
  14.                 TR0=1;
  15.                 P0=discode1[second/10];
  16.                 P2=discode2[second%10];
  17.                 while(1)
  18.                 {
  19.                         
  20.                 }

  21. }
  22. void int_T0() interrupt 1 using 0
  23. {
  24.         TR0=0;
  25.         TH0=0xee;
  26.         TL0=0x00;
  27.         timer ++;
  28.         if(timer==200)
  29.         {
  30.                 timer = 0;
  31.                 second ++;
  32.                 P0=discode1[second/10];
  33.                 P2=discode2[second%10];
  34.         }
  35.         if(second==60)
  36.         {
  37.                 TR0=0;
  38.                 second=0;
  39.         }
  40.         else
  41.         {
  42.                 TR0=1;
  43.         }
  44. }
復制代碼

所有資料51hei提供下載:
jishi.zip (18.68 KB, 下載次數: 13)

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

使用道具 舉報

沙發
ID:278840 發表于 2020-11-28 17:39 | 只看該作者
你是有問題,還是叫人幫你寫啊?樓主
回復

使用道具 舉報

板凳
ID:278840 發表于 2020-11-28 17:42 | 只看該作者
驗證過了,程序電路都沒有問題
回復

使用道具 舉報

地板
ID:278840 發表于 2020-11-28 17:50 | 只看該作者
  1. //0-59自動計數器
  2. //跳線設置:默認
  3. #include<reg51.h>
  4. unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  5. unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  6. unsigned char timer=0;
  7. unsigned char second;
  8. bit back;
  9. main()
  10. {
  11.                 TMOD = 0x01;        
  12.                 EA=1;            //總中斷打開
  13.                 ET0=1;           //定時器中斷打開
  14.                 second=0;
  15.                 TR0=1;
  16.                 P0=discode1[second/10];
  17.                 P2=discode2[second%10];
  18.                 while(1)
  19.                 {
  20.                         
  21.                 }

  22. }
  23. void int_T0() interrupt 1 using 0
  24. {
  25.         TR0=0;
  26.         TH0=0xee;
  27.         TL0=0x00;
  28.         timer ++;
  29.                 TR0 = 1;
  30.         if(timer==200)
  31.         {
  32.                 timer = 0;
  33.                                 if(second==0)
  34.                                 {
  35.                         back = 0;
  36.                                 }
  37.                                 if(second==60)
  38.                                 {
  39.                                         back = 1;
  40.                                 }
  41.                                 if(back==0)
  42.                                 {
  43.                                         second++;
  44.                                 }
  45.                                 else
  46.                                 {
  47.                                         second--;
  48.                                 }

  49.                 P0=discode1[second/10];
  50.                 P2=discode2[second%10];
  51.                        
  52.         }
  53.       
  54. }
  55. 帶返回的
復制代碼

評分

參與人數 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復

使用道具 舉報

5#
ID:838732 發表于 2020-11-28 18:10 | 只看該作者
  //0-59自動計數器
//跳線設置:默認
#include<reg51.h>
unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char second;
unsigned int timer;
void main()
{
                TMOD = 0x01;        
                EA=1;            //總中斷打開
                ET0=1;           //定時器中斷打開
                second=0;
                TR0=1;
                 while(1)
                                 {
                                   if(second<60)
                                   {P0=~discode1[second/10];
                   P2=~discode2[second%10];
                                   }
                   else if(second==60)
                                   {second=0;}   
                   }
}
void int_T0() interrupt 1 using 0
{
                TH0=0xee;
        TL0=0x00;

        timer ++;
        if(timer==200)
        {
                timer = 0;
                second ++;

        }

}
我改了下程序,我的電路是共陽的,所以取反,測試時可行的,你試試
回復

使用道具 舉報

6#
ID:278840 發表于 2020-11-28 18:16 | 只看該作者
HAISONC 發表于 2020-11-28 18:10
//0-59自動計數器
//跳線設置:默認
#include

[code]
  //0-59自動計數器
//跳線設置:默認
#include<reg51.h>
unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char second;
unsigned int timer;
void main()
{
                TMOD = 0x01;        
                EA=1;            //總中斷打開
                ET0=1;           //定時器中斷打開
                second=0;
                TR0=1;
                 while(1)
                                 {
                                   if(second<60)
                                   {P0=discode1[second/10];
                   P2=discode2[second%10];
                                   }
                   else if(second==60)
                                   {second=0;}   
                   }
}
void int_T0() interrupt 1 using 0
{
                TH0=0xee;
        TL0=0x00;

        timer ++;
        if(timer==200)
        {
                timer = 0;
                second ++;

        }

}//這個是循環計時我驗證過了
回復

使用道具 舉報

7#
ID:535215 發表于 2020-11-28 18:28 | 只看該作者
#include<reg51.h>
unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char second;
unsigned int timer;
void main()
{
                TMOD = 0x01;        
                EA=1;            //總中斷打開
                ET0=1;           //定時器中斷打開
                second=0;
                TR0=1;
                 while(1)
                                 {
                                   if(second<60)
                                   {P0=discode1[second/10];
                   P2=discode2[second%10];
                                   }
                   else if(second==60)
                                   {second=0;}   
                   }
}
void int_T0() interrupt 1 using 0
{
                TH0=0xee;
        TL0=0x00;

        timer ++;
        if(timer==200)
        {
                timer = 0;
                second ++;

        }

}
按照這個來 你試一試
回復

使用道具 舉報

8#
ID:825693 發表于 2020-12-15 12:29 | 只看該作者
統一回復下,這是做的一個分享作品,不是求幫的
回復

使用道具 舉報

9#
ID:860490 發表于 2020-12-15 12:51 | 只看該作者
驗證過了,程序電路都沒有問題
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 欧美一区二区精品 | 日本黄色免费网站 | 国产最新av| www.久久精品 | 黄色片网站在线观看 | 欧美成人精品激情在线观看 | 国内精品久久久久久久久 | 精品国产乱码久久久久久蜜臀网站 | 成人动漫在线观看 | 欧美在线一区二区三区 | 久久激情综合 | 成人黄色在线视频 | 天堂成人在线 | 青青草免费在线视频 | 五月天激情国产综合婷婷婷 | 三级在线观看视频 | 日韩一区二区三区在线播放 | 国产中文字幕视频 | 一区二区三区国产视频 | 五月天激情婷婷 | 色婷婷一区 | 国产精品视频在线观看 | 中文字幕在线观看免费视频 | 日韩视频精品 | www.com国产| 国产一级生活片 | 国产精品免费一区二区三区 | 久久综合av| 久久不雅视频 | 欧美a级黄色片 | 色妞色视频一区二区三区四区 | 国产精品视频专区 | 欧美中文字幕在线 | 亚洲精品成人网 | 玖玖视频在线 | 一级特黄色片 | 黄色一级免费 | 黄色片视频 | av免费在线观看网站 | 久久精品欧美一区二区 | 少妇高潮av久久久久久 |