完整版 电路图和程序代码 下载地址
https://pan.baidu.com/s/18DxtCIfC_eiU1pDw9DKiaQ?pwd=8888
部分代码展示
#include <reg51.h>
#include <Intrins.h>
#include <LCD1602.H>
#include <math.H>
#define C02_write 0xa0 /* c02写地址 */
#define C02_read 0xa1 /* c02读地址 */
#define uchar unsigned char
#define uint unsigned int
sbit MAX6675_CS = P1 ^ 2; /* MAX6675冷端温度补偿,将K型热电偶信号转为数字信号 */
sbit MAX6675_SCK = P1 ^ 1;
sbit MAX6675_SO = P1 ^ 0;
sbit normal = P2 ^ 3; /* LED灯表示温度正常,过高,过低 */
sbit upper = P2 ^ 4;
sbit lower = P2 ^ 5;
sbit direction = P2 ^ 6;
sbit stop = P2 ^ 7;
sbit SCL = P1 ^ 3; /* EEPROM,256byte */
sbit SDA = P1 ^ 4;
sbit beep = P1 ^ 7; /* 蜂鸣器 */
bit ack, flag = 0, flag1 = 0;
uint tz;
int sth = 0, stl = 0, t_zhi = 0;
uchar data temp1[] = { '+', '1', '5', '0', '0', 0 }, temp2[] = { '-', '1', '0', '0', '0', 0 };
uchar data temp[7];
char code keytab[] = { 0xEE, 0xDE, 0xBE, 0x7E, 0xED, 0xDD, 0xBD, 0x7D, 0xEB, 0xDB, 0xBB, 0x7B, 0xE7, 0xD7, 0xB7, 0x77 };
unsigned char code str1[] = { "STH STL" }; /* system temperature high,low */
unsigned char code str2[] = { "PARAMTER STEUP" };
unsigned char code str3[] = { " " };
unsigned int testD2;
unsigned char data disdata[5];
void delay0( uchar x ) /* 延时函数 */
{
uchar i;
while ( x-- )
{
for ( i = 0; i < 13; i++ )
;
}
}
void delayms( uchar i )
{
uchar j;
for (; i > 0; i-- )
for ( j = 124; j > 0; j-- )
;
}
void longdelay( uchar i )
{
uint j;
for (; i > 0; i-- )
for ( j = 10000; j > 0; j-- )
;
}
void keysound() /*按键声音函数 */
{
uchar i;
for ( i = 0; i < 180; i++ )
{
delay0( 5 );
beep = !beep; /* BEEP取反 */
}
}
void I2C_start( void ) /* I2C开始信号 */
{
SDA = 1; SCL = 1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SDA = 0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SCL = 0; _nop_(); _nop_();
}
void I2C_stop( void ) /* I2C结束 */
{
SDA = 0; SCL = 1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SDA = 1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SCL = 0;
_nop_(); _nop_();
}
void I2C_no_ackownledge( void ) /* 发送noack信号 */
{
SDA = 1;
_nop_(); _nop_();
SCL = 1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SCL = 0;
_nop_(); _nop_(); _nop_();
}
void I2C_sendB( uchar byte ) /* 发送一字节数据 */
{
uchar counter;
for ( counter = 0; counter < 8; counter++ )
{
if ( byte & 0x80 )
SDA = 1;
else SDA = 0;
_nop_();
SCL = 1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SCL = 0;
_nop_(); _nop_();
byte <<= 1;
}
_nop_(); _nop_();
SDA = 1;
_nop_(); _nop_(); _nop_();
SCL = 1;
_nop_(); _nop_(); _nop_();
if ( SDA == 0 )
ack = 1;
else ack = 0;
SCL = 0;
_nop_(); _nop_();
}