欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 這個程序,如果想定時時間為小時,怎樣時間到,LED燈滅,調(diào)整時間按一次加鍵,加5... [打印本頁]

作者: 江西奉新    時間: 2019-6-22 15:11
標(biāo)題: 這個程序,如果想定時時間為小時,怎樣時間到,LED燈滅,調(diào)整時間按一次加鍵,加5...
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit led=P2^0;
sbit wea=P2^2;
sbit web=P2^3;
sbit wec=P2^4;
sbit fm=P1^5;
sbit sw1=P3^1;
sbit sw2=P3^0;
sbit sw3=P3^2;
sbit sw4=P3^3;
uchar code duma[]={0x3f,0x06,0x5b,0x4f,
                                   0x66,0x6d,0x7d,0x07,
                                   0x7f,0x6f,0x77,0x7c,
                                   0x39,0x5e,0x79,0x71
                                   };
                               
                                 
uchar time ,counter,time_counter;                               
                               
                               
                               
uchar i ;

void delay(uint z);
void delay(uint z)
{
  while (z--);

}
void display(uchar i)
{        uchar shi,ge,qie;
shi=i%100/10;
ge=i%10;
qie=i/100;
P0=0XFF;
wea=0;
web=0;
wec=0;
  P0=duma[ge];
  delay(41);
   P0=0XFF;
wea=1;
web=0;
wec=0;
  P0=duma[shi];
  delay(41);
   P0=0XFF;
wea=0;
web=1;
wec=0;
  P0=duma[qie];
  delay(41);
}

void keypros()
{
        if(sw1==0)
        {
           delay(10);
           if(sw1==0)
           {
                   time_counter++;
               
                  while(!sw1);
           }
        }       
         if(sw2==0)
         {
          delay(10);
          if(sw2==0&&time_counter!=0)
          {
                  time_counter--;
       
                   while(!sw2);
          }
         }
         if(sw3==0)
         {
           delay(10);
           if(sw3==0)
           {
                     TR1=0;
                  led=1;
                  time_counter=0;
                while(!sw3);
               
           }
         
         
         
         }
          if(sw4==0)
          {
           delay(10);
          
           if(sw4==0)
           {
                   TR1=~TR1;
                led=~led;
                while(!sw4);
           }
          
          }
}

void init()
{
  TMOD=0x10;
  TH1=0x4b;
  TL1=0x00;
  TR1=0;



}


void main()
{       

             
                         init();
                        
    while(1)
        {       
        keypros();         
   if(TF1==1)
   { TF1=0;
            TH1=0x4b;
     TL1=0x00;
            counter++;


   }
         if(counter==10)
        {
         counter=0;
         time_counter++;
        }
        if(time_counter==240)

         time_counter=0;
          
         display(time_counter);
          
          
   }
}


作者: 江西奉新    時間: 2019-6-22 15:14
補充,時間到燈滅,加鍵,按一次加5分鐘,減鍵一次,減5分鐘,定時間為小時,顯示為分鐘數(shù)
作者: xianfajushi    時間: 2019-6-22 20:14
加5修改: if(sw1==0)time_counter+=5;判斷時間的時參數(shù)到指定值那么執(zhí)行LED即可
作者: xianfajushi    時間: 2019-6-22 20:18
假設(shè)這個為定時值判斷 if(time_counter==240){ time_counter=0; led=~led;}那么修改判斷式中的參數(shù)就是你要的小時值
作者: xianfajushi    時間: 2019-6-23 10:33
把仿真與程序所有打包發(fā)出來以便修改




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