📄 wdjk.c
字号:
#include <reg52.h>
#include <intrins.h>
#include "18b20.h"
#include "key.h"
#include "24c02.h"
#include "uln2003.h"
#include "timer.h"
#include "display.h"
#define uchar unsigned char
#define uint unsigned int
uchar tempdata[8]={3,0,2,3,11,11,0,0};
uchar temperature;
uint times;
sbit wave1=P3^4;
sbit wave2=P3^5;
sbit relay=P0^4;
bit rdflag=1;
main()
{
uchar up=30,down=10,num;
Init_timer0();
Init_timer1();
relay=0;
buzz=0;
ULN2003_Latch();
relay=0;buzz=0;
ULN2003_Latch();
while(1)
{
num=KeyScan();
switch(num)
{
case 0:{ //下限减一
if(down==0)
down=1;
down--;
tempdata[2]=down/10;
tempdata[3]=down%10;
wrbyte_24c02(0x01,down);
break;
}
case 1:{ //上限减一
if(up<=down)
up++;
up--;
tempdata[0]=up/10;
tempdata[1]=up%10;
wrbyte_24c02(0x00,up);
break;
}
case 2:{ //下限加一
if(down>=up)
down--;
down++;
tempdata[2]=down/10;
tempdata[3]=down%10;
wrbyte_24c02(0x01,down);
break;
}
case 3:{ //上限加一
if(up==99)
up=98;
up++;
tempdata[0]=up/10;
tempdata[1]=up%10;
wrbyte_24c02(0x00,up);
break;
}
default:break;
}
if(rdflag)
{
//rdflag=0;
temperature=rd_temperature();
tempdata[6]=temperature/10;
tempdata[7]=temperature%10;
}
if(temperature>up)
{
TR0=1;
TR1=1;
}
else
{
if(temperature<down)
{
relay=1;buzz=0;
ULN2003_Latch();
}
else
{
TR0=0;
TR1=0;
wave1=1;
wave2=1;
relay=0;buzz=0;
ULN2003_Latch();
}
}
display(tempdata);
}
}
Isr_timer0() interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
//times++;
TR1=1;
wave1=1;
/* if(times==1000)
{
times=0;
rdflag=1;
} */
}
Isr_timer1() interrupt 3
{
TH1=(65536-300)/256;
TL1=(65536-300)%256;
wave1=0;
TR1=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -