找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

51单片机多路延时控制器小制作

查看数: 7332 | 评论数: 5 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-8-22 16:39

正文摘要:

设备上的除尘反吹控制器损坏,更换新的后,感觉程序不是很难,自己突发想法写一个程序 做电工,爱好单片机,查资料开始的路走弯了很多,一直纠结在设置好后怎样读取数值,再循环倒计时,开始倒计时完后不知道怎样 ...

回复

ID:867960 发表于 2021-6-26 13:53
有点复杂,,,,,,,,,,,
ID:784783 发表于 2020-6-20 10:41
哪里买的单片机
ID:89072 发表于 2018-8-22 16:43
void xsdata(uchar aa,uchar bb,uchar cc,uchar dd)//显示函数
{
/*******       
        aa=shu/1000;
        bb=shu%1000/100;
        ********/
        aa=num%100/10;
        bb=num%10;
                       
        cc=shu%100/10;
        dd=shu%10;
               
        we1=0;
        P0=table[aa];
        delay_50ms(10);
        P0=0xff;
        we1=1;
       
        we2=0;
        P0=table[bb];
        delay_50ms(10);
        P0=0xff;
        we2=1;
       
        we3=0;
        P0=table[cc];
        delay_50ms(10);
        P0=0xff;
        we3=1;

        we4=0;
        P0=table[dd];
        delay_50ms(10);
        P0=0xff;
        we4=1;
}
ID:89072 发表于 2018-8-22 16:42
/************中断函数****************/
void timer0() interrupt 1                //中断函数
{
        uchar t0;
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        t0++;
        if(t0==20)
        {
                t0=0;
                shu--;
                if(shu==0)
                {
                        shu=shu1;
                        num--;
                          
                        if(num==0)
                        {
                                P1<<=1;
                           P1=P1|0x01;     //左移后,最右端自动赋值0,所以需要该语句赋值1
                           if(P1==0x7f)
                           P1=0xfe;
                                num=num1;
                         }
                }
        }
}
ID:89072 发表于 2018-8-22 16:41
/************按键控制部分****************/
void key() //按键
{
                if(s1==0)
                {
                        delay_50ms(10);
                        if(s1==0)
                        {                       
                                while(!s1);
                                c1++;
                        }
                }
        if(c1==1)                  //时间设置
        {
                if(s2==0)
                {
                        delay_50ms(5);
                        if(s2==0)
                        {
                        while(!s2);
                        shu1--;
                        }
                }
                if(s3==0)
                {
                        delay_50ms(5);
                        if(s3==0)
                        {
                                 while(!s3);                       
                                 shu1++;
                         }
                }
        }
        if(c1==2)                                        //循环次数设置
        {
                if(s2==0)
                {
                        delay_50ms(5);
                        if(s2==0)
                        {
                                while(!s2);
                                num1--;
                        }
               
                }
                if(s3==0)
                {
                        delay_50ms(5);
                        if(s3==0)
                        {
                                 while(!s3);                       
                                 num1++;
                         }
                         
                }       
        }
}

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表