467【Complete course design】Based on 51 single chip microcomputer intelligent greenhouse sensor detection and control system design

[Resource Download] The download address is as follows:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl

Set up a greenhouse model (simulated with a shoe box), and cover the top layer with a layer of transparent plastic cling film.
The design consists of 51 single-chip circuit,
1602 liquid crystal display circuit,
light detection circuit, and
soil moisture detection circuit.

A/D module PCF8591 circuit,

1 high-brightness LED lamp fill light circuit,
temperature detection DS18B20 circuit,
1 yellow high-bright LED lamp heating circuit,

Fan circuit,
water pump irrigation circuit,
4-position button circuit,

1. Detect the light intensity through the photoresistor, and then process the A/D module PCF8591 to display the light intensity value on the LCD in real time, and you can control the light intensity value by pressing the button.
When the light is lower than the set threshold, 1 white high Turn on the LED light to fill up the light. If the light is higher than the set threshold, just ignore it.
2. The temperature value is detected by DS18B20 and displayed on the 1602 LCD in real time, and the temperature value can be set by pressing the button. When the temperature is lower than the set value, it is simulated by a yellow bright LED light. When the temperature exceeds the set value, the fan rotates.
3. The soil moisture is detected by the soil moisture sensor, and the moisture value is displayed on the LCD in real time, and the reader can be set to the soil. When the soil moisture is less than the set threshold, the water pump will add water. When it is greater than the threshold, no action.

#include<reg52.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义
#include<stdio.h>
#include "1602.h"
#include "delay.h"
#include "sysdefine.h"
#include"18b20.h"

sbit led_l = P1^0;
sbit led_b = P1^1;
sbit fan = P1^4;
sbit relay = P1^3;

sbit key_s = P3^4;
sbit key_a = P3^5;
sbit key_u = P3^6;

void Init_Timer0(void);

unsigned char readTem = FALSE ;//定义读时间标志
unsigned char readADCFlag = FALSE ;

int temp;
float temperature = 0;

char disdat[16];			   //打印数组初始化
char disset[16];
unsigned long time_20ms=0;		   //定时器计数

float Lv=0.0;		  	//光照采集电压
float Tv=0.0;				  //土壤采集电压
unsigned int Lval =0;		 //光照强度
unsigned int Rval = 0;		 //土壤湿度
unsigned int distem;
unsigned char rekey = 0;
unsigned char SetFlag = 0; 		//设置值
unsigned char setLval = 50;
unsigned char setRval = 50;
unsigned char setTval = 30;

void main (void)
{     
	unsigned char midval;             
	Init_Timer0();

	LCD_Init();           //初始化液晶
	DelayMs(20);          //延时有助于稳定
	LCD_Clear();          //清屏
	sprintf(disdat,"L:%2d R:%2d T:%2d C",Lval,Rval,distem);//打印电压电流值
	LCD_Write_String(0,0,disdat);//显示
	sprintf(disset," L:%2d R:%2d T:%2d",(unsigned int)setLval,(unsigned int)setRval,(unsigned int)setTval);//打印电压电流值
	LCD_Write_String(0,1,disset);
	while (1)         //主循环
	{
		

Guess you like

Origin blog.csdn.net/weixin_51254112/article/details/109562502