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

標題: 89C52RC單片機做自動喂食機 [打印本頁]

作者: jinweidong    時間: 2018-11-13 17:28
標題: 89C52RC單片機做自動喂食機
閑來無事,給家里狗狗制作了自動喂食機,
代碼如下:
#include<reg52.h>
sbit led1=P2^0;
sbit led2=P2^1;
sbit led3=P2^2;
sbit led4=P2^3;
sbit led5=P2^4;
sbit led6=P2^5;
sbit FZ  =P3^7;
sbit IN1=P1^3;
sbit IN2=P1^2;
sbit IN3=P2^7;
sbit IN4=P2^6;
void Delay10ms(unsigned int c) ;

unsigned char code LedChar[]={
        0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78,
        0x00, 0x10
        };

unsigned char LedBuff[]={
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff
        };
unsigned int cnt = 0;

void main()
{         

               
        unsigned long sec;
        sec=0x00;
    TMOD = 0x01;
        TH0 = 0xFC;
        TL0 = 0x66;
        TR0 = 1;
        EA = 1;
        ET0 = 1;
                 
            
       while(1)
        {        
                   if(cnt >= 1000)
                {
                        cnt = 0;
                        sec++;
                        
                        
                        //if(sec==20)
                ////        {
                //        FZ=0;Delay5ms(50)        ;FZ=1;Delay5ms(50)        ; FZ=0;Delay5ms(50);          FZ=1;Delay5ms(50);
                //         IN1=1;IN2=0;  Delay5ms(50)        ;IN1=0;IN2=1;         Delay5ms(50)        ;
                //         IN1=1;IN2=0;  Delay5ms(50)        ;IN1=0;IN2=1;          Delay5ms(50)        ;
                //         IN1=IN2=0;
                //        }
                        
                        LedBuff[0] = LedChar[sec%3600%60%10];
                        LedBuff[1] = LedChar[sec%3600%60/10];
                        LedBuff[2] = LedChar[sec%3600/60%10];
                        LedBuff[3] = LedChar[sec%3600/60/10];
                        LedBuff[4] = LedChar[sec/3600%10];        
                        LedBuff[5] = LedChar[sec/3600/10];        
                        
        
               if(sec>=43200)
              {
        
                 sec=0;
        
        
              }

                }                    
        }
}

unsigned char i = 0;
void InterruptTimer0()  interrupt 1                 
{
        TH0 = 0xFC;
        TL0 = 0x66;
        cnt++;
        P0=P2 = 0xff;
        switch(i)
        {
                case 0:led1=0; i++; P0=LedBuff[0];break;
                case 1:led2=0; i++; P0=LedBuff[1];break;
                case 2:led3=0; i++; P0=LedBuff[2];break;
                case 3:led4=0; i++; P0=LedBuff[3];break;
                case 4:led5=0; i++; P0=LedBuff[4];break;
                case 5:led6=0; i=0; P0=LedBuff[5];break;
        default:break;
        }
}//
void Delay10ms(unsigned int c)   
{
    unsigned char a, b;

        
    for (;c>0;c--)
        {
                for (b=249;b>0;b--)
                {
                        for (a=17;a>0;a--);
                }         
        }
}


作者: 電子發燒友jm    時間: 2021-1-30 00:09
有電路圖




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