通过X方向和Y方向的模拟量传感器进行采集模拟值,内置报警范围。包含的电路有自检电路,显示电路,传感器电路,AD采集电路,声光报警电路。
#include <reg52.h> /* 包含头文件 */
#include <math.h>
#include "uart.h"
#include "display.h"
#define uint unsigned int
#define uchar unsigned char /* 宏定义 */
sbit ale = P2 ^ 6;
sbit start = P2 ^ 7;
sbit eoc = P3 ^ 2;
sbit oe = P3 ^ 3; /* 定义adc0809的控制引脚 */
sbit adda = P2 ^ 0;
sbit addb = P2 ^ 1;
sbit addc = P2 ^ 2; /* adc0809的地址引脚 */
/*
* sbit rs=P2^3;
* sbit rw=P2^4;
* sbit en=P2^5; //液晶的控制引脚
*/
unsigned long voltdata[8];
uint i, j, k, l, t, sum, a[5]; /* 定义全局变量 */
unsigned char CH;
uchar add; /* 地址变量 */
long TxBuf[8]; /* 四个显示的位 */
long realvolt;
unsigned char t0Count;
unsigned char flagAu = 1;
bit Aflag = 0;
bit Bflag = 0;
bit Check = 0;
sbit LED = P3^0; //声光报警
sbit BUZ = P3^1; //声光报警
sbit KEY = P3^4; //自检按键
sbit ALE = P3^5; //自检指示