【资源下载】下载地址如下:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
使用proteus打开原理图文件,双击AT89C52,将hex文件添加,运行即可。如需要更改代码,在main.c中更改即可。
sbit CS=P1^1; //ADC片选 sbit DI=P1^4; //ADC输入 sbit DO=P1^5; //ADC输出 sbit CLK=P1^0; //ADC时钟信号 sbit FAN=P2^5; sbit SP2=P2^6; sbit LEDR=P1^6; sbit LEDG=P1^7; sbit SCK=P1^2; sbit DATA=P1^3; sbit ADCS=P0^0; sbit ADCLK=P0^1; sbit ADDO=P0^2; sbit HEAT=P0^3; sbit s485_s = P3^3; //485控制信号 #define DISPLAY_LEFT_TO_RIGHT 1//从左边数计算列位置,每写完一个字节,列数自动向右移动一个 #define DISPLAY_RIGHT_TO_LEFT 0//从右边数计算列位置,每写完一个字节,列数自动向左移动一个 #define uchar unsigned char /* 1光强 6温度 10湿度 14CH4 18CO 22气压 26加热炉温度 */ char data_res[32]={' ',0x30,0x30,0x30,' ','+',0x30,0x30,0x30,' ',0x30,0x30,0x30,' ',0x30,0x30,0x30,' ',0x30,0x30,0x30,' ',0x30,0x30,0x30,' ',0x30,0x30,0x30,' '}; //数据返回形式1 char data_n[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39}; int Num; /* void busy_1602() //判忙LCD忙闲? { do { P2=0xff; RS=0; //RS=0,RW=1时才可读忙信号 RW=1; E=0; _nop_(); E=1; }while(bflag); //当其值为0时,表示不忙,才可以接收命令或者数据信号 } void wreg_1602(unsigned char com) //函数功能:写指令函数 { busy_1602(); RS=0; //当RS=0,RW=0时,表明写入的是命令 RW=0; E=1; P2=com; //当使能由高到低时,LCD执行相应命令 E=0; } void wdata_1602(unsigned char dat) //函数功能:写数据函数 { busy_1602();