设备上的除尘反吹控制器损坏,更换新的后,感觉程序不是很难,自己突发想法写一个程序 做电工,爱好单片机,查资料开始的路走弯了很多,一直纠结在设置好后怎样读取数值,再循环倒计时,开始倒计时完后不知道怎样赋值,很郁闷,再QQ群问大师们都感觉太简单没有告诉,现在只有靠自己,摸索了近一个礼拜,程序部分已经测试通过。 |
原来设备上的,已坏程序不知道,只知道原理
程序测试通过,时间循环次数100以内可调
23.72 KB, 下载次数: 13, 下载积分: 黑币 -5
/************按键控制部分****************/
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++;
}
}
}
}
/************中断函数****************/ 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; } } } } 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; } |
联系客服