基于单片机智能鱼缸系统仿真设计-资料
说明:
1.能够分别检测鱼缸和室内温度并显示2.能够实现鱼缸温度自动调节(升温降温恒温)3.系统能够实现
依据被投食设定相应的定时时间。4.系统可以实现自动和手动模式功能。注:仿真中调节温度是有抖动,
正常现象。
#include <REGX51.H>
#include "1602.H"
#include "DS18B20.h"
extern void DelayMs( unsigned char t );
unsigned int Temp[5]; /* 温度值温度放大10倍 */
int DS18B20DATA[3]; /* DS18B20读到的16位数据 */
code unsigned char DecimalNum[16] = { 0, 1, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 9 }; /* DS18B20小数部分对应的数 */
unsigned char code DuanMa[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f };
sbit LED = P3 ^ 1; /* LED报警 */
sbit LE = P3 ^ 0;
sbit Key = P2 ^ 6;
sbit SET = P1 ^ 7; /* 设置键 */
sbit ADD = P3 ^ 3; /* 加++1 */
sbit DEC = P3 ^ 4; /* 减--1 */
sbit UP = P2 ^ 3;
sbit DOWN = P2 ^ 4;
sbit LED1 = P1 ^ 0;
sbit LED2 = P1 ^ 1;
sbit LED3 = P1 ^ 2;
sbit GAO = P3^6;
sbit DI = P3^7;
sbit CHU = P1^3;
sbit JIN = P1^4;
sbit WEI = P1^5;
unsigned char flag = 1;
unsigned char CurID; /* 路数ID */
unsigned int s = 430; /* 温度上限 放大十倍 */
unsigned int t = 310; /* 温度下限 放大十倍 */
unsigned int a = 1200; /* 温度上限 放大十倍 */
unsigned int num = 0; /* 50ms */
unsigned int time = 0;
/* 显示段码值01234567 */
unsigned char LCDbuf[16];
bit display = 0;
bit timeFlag = 0;
/* DS18B20温度读取 */
void DS18B20Read()
{
gettemp( DS18B20DATA );
Temp[2] = (DS18B20DATA[0] >> 4) * 10 + DecimalNum[DS18B20DATA[0] & 0x0f];