|
光照檢測(cè),外圍環(huán)境變暗時(shí),指示燈亮,5s后指示燈滅,生物補(bǔ)給燈亮,外圍環(huán)境恢復(fù)光亮?xí)r,生物補(bǔ)給燈滅,
土壤濕度檢測(cè),土壤過(guò)干時(shí),水泵抽水,土壤變濕潤(rùn)時(shí),水泵停止工作
溫度檢測(cè),溫度過(guò)高時(shí),風(fēng)扇啟動(dòng),使空氣流通來(lái)降溫,溫度適宜時(shí),風(fēng)扇停止,12864會(huì)顯示這三個(gè)環(huán)境因素的情況
單片機(jī)源程序:
- #include<reg52.h>
- #include "dht12.h"
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- ///*TS12864A-3 端口定義*/
- //#define LCD_data P0 //數(shù)據(jù)口
- //sbit LCD_RS = P3^4; //寄存器選擇輸入
- //sbit LCD_RW = P3^5; //液晶讀/寫控制
- //sbit LCD_EN = P3^6; //液晶使能控制
- //sbit LCD_PSB = P3^7; //串/并方式控制
- ///* 89c52 端口定義*/
- //sbit turang=P1^3;
- //sbit choushui=P2^5;
- //sbit feng=P1^7;
- sbit guang=P2^1;
- sbit zhao=P2^2;
- sbit guangbu=P2^4;
- //uchar chun ;
- //uchar i;
- //uchar code dis1[] = {"智能花卉培養(yǎng)裝置"};
- //uchar code dis2[] = {"光照:"};
- //uchar code dis3[] = {"溫度:"};
- //uchar code dis4[] = {"濕度:"};
- //uchar code dis5[] = {"適宜"};
- //uchar code dis6[] = {"較暗"};
- //uchar code dis7[] = {"適宜"};
- //uchar code dis8[] = {"偏高"};
- //uchar code dis9[] = {"適宜"};
- //uchar code dis0[] = {"干燥"};
- //
- //#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
- //uchar IRDIS[2];
- //uchar IRCOM[4];
- //void delay0(uchar x); //x*0.14MS
- //void beep();
- //void dataconv();
- //void lcd_pos(uchar X,uchar Y); //確定顯示位置
- /*******************************************************************/
- /* */
- /* 延時(shí)函數(shù) */
- /* */
- /*******************************************************************/
- void delay(int ms)
- {
- while(ms--)
- {
- uchar i;
- for(i=0;i<250;i++)
- {
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- }
- }
- }
- /*******************************************************************/
- /* */
- /*檢查L(zhǎng)CD忙狀態(tài) */
- /*lcd_busy為1時(shí),忙,等待。lcd-busy為0時(shí),閑,可寫指令與數(shù)據(jù)。 */
- /* */
- /*******************************************************************/
- //bit lcd_busy()
- // {
- // bit result;
- // LCD_RS = 0;
- // LCD_RW = 1;
- // LCD_EN = 1;
- // delayNOP();
- // result = (bit)(P0&0x80);
- // LCD_EN = 0;
- // return(result);
- // }
- ///*******************************************************************/
- ///* */
- ///*寫指令數(shù)據(jù)到LCD */
- ///*RS=L,RW=L,E=高脈沖,D0-D7=指令碼。 */
- ///* */
- ///*******************************************************************/
- //void lcd_wcmd(uchar cmd)
- //{
- // while(lcd_busy());
- // LCD_RS = 0;
- // LCD_RW = 0;
- // LCD_EN = 0;
- // _nop_();
- // _nop_();
- // P0 = cmd;
- // delayNOP();
- // LCD_EN = 1;
- // delayNOP();
- // LCD_EN = 0;
- //}
- ///*******************************************************************/
- ///* */
- ///*寫顯示數(shù)據(jù)到LCD */
- ///*RS=H,RW=L,E=高脈沖,D0-D7=數(shù)據(jù)。 */
- ///* */
- ///*******************************************************************/
- //void lcd_wdat(uchar dat)
- //{
- // while(lcd_busy());
- // LCD_RS = 1;
- // LCD_RW = 0;
- // LCD_EN = 0;
- // P0 = dat;
- // delayNOP();
- // LCD_EN = 1;
- // delayNOP();
- // LCD_EN = 0;
- //}
- ///*******************************************************************/
- ///* */
- ///* LCD初始化設(shè)定 */
- ///* */
- ///*******************************************************************/
- //void lcd_init()
- //{
- // LCD_PSB = 1; //并口方式
- //
- // lcd_wcmd(0x34); //擴(kuò)充指令操作
- // delay(5);
- // lcd_wcmd(0x30); //基本指令操作
- // delay(5);
- // lcd_wcmd(0x0C); //顯示開,關(guān)光標(biāo)
- // delay(5);
- // lcd_wcmd(0x01); //清除LCD的顯示內(nèi)容
- // delay(5);
- //}
- ///**************************************/
- // /*********************************************************/
- ///* */
- ///* 延時(shí)x*0.14ms子程序 */
- ///* */
- ///*********************************************************/
- //void delay0(uchar x) //x*0.14MS
- //{
- // uchar i;
- // while(x--)
- // {
- // for (i = 0; i<13; i++) {}
- // }
- //}
- ///*********************************************************/
- ///* */
- ///* 設(shè)定顯示位置 */
- ///* */
- ///*********************************************************/
- //void lcd_pos(uchar X,uchar Y)
- //{
- // uchar pos;
- // if (X==0)
- // {X=0x80;}
- // else if (X==1)
- // {X=0x90;}
- // else if (X==2)
- // {X=0x88;}
- // else if (X==3)
- // {X=0x98;}
- // pos = X+Y ;
- // lcd_wcmd(pos); //顯示地址
- //}
- //void Lcd()
- //{
- // /*************************************/
- // /******** 顯示屏初始化 ********/
- // /*************************************/
- // /*************************************/
- // delay(10); //延時(shí)
- // lcd_init(); //初始化LCD
- //
- // /*************************************/
- // /******** 顯示屏 ********/
- // /***************第一行*****************/
- // /*************************************/
- // lcd_pos(0,0); //設(shè)置顯示位置為第一行的第1個(gè)字符
- // i = 0;
- // while(dis1[i] != '\0')
- // { //顯示字符
- // lcd_wdat(dis1[i]);
- // i++;
- // }
- // /*************************************/
- // /******** 顯示屏 ********/
- // /***************第二行*****************/
- // /*************************************/
- // lcd_pos(1,0); //設(shè)置顯示位置為第二行的第1個(gè)字符
- // i = 0;
- // while(dis2[i] != '\0')
- // {
- // lcd_wdat(dis2[i]); //顯示字符
- // i++;
- // }
- // lcd_pos(1,3); //設(shè)置顯示位置為第二行的第4個(gè)字符
- // i = 0;
- // if(guang==0)
- // {
- // while(dis5[i] != '\0')
- // {
- // lcd_wdat(dis5[i]); //顯示字符
- // i++;
- // }
- // }
- // else
- // {
- // while(dis6[i] != '\0')
- // {
- // lcd_wdat(dis6[i]); //顯示字符
- // i++;
- // }
- // }
- // /*************************************/
- // /******** 顯示屏 ********/
- // /***************第三行*****************/
- // /*************************************/
- // lcd_pos(2,0); //設(shè)置顯示位置為第三行的第1個(gè)字符
- // i = 0;
- //
- // while(dis3[i] != '\0')
- // {
- // lcd_wdat(dis3[i]); //顯示字符
- // i++;
- // }
- // lcd_pos(2,3); //設(shè)置顯示位置為第三行的第4個(gè)字符
- // i = 0;
- // if(chun<25)
- // {
- // while(dis7[i] != '\0')
- // {
- // lcd_wdat(dis7[i]); //顯示字符
- // i++;
- // }
- // }
- // else
- // {
- // while(dis8[i] != '\0')
- // {
- // lcd_wdat(dis8[i]); //顯示字符
- // i++;
- // }
- // }
- // /*************************************/
- // /******** 顯示屏 ********/
- // /***************第四行*****************/
- // /*************************************/
- // lcd_pos(3,0); //設(shè)置顯示位置為第四行的第1個(gè)字符
- // i = 0;
- // while(dis4[i] != '\0')
- // {
- // lcd_wdat(dis4[i]); //顯示字符
- // i++;
- // }
- // lcd_pos(3,3); //設(shè)置顯示位置為第四行的第4個(gè)字符
- // i = 0;
- // if(turang==0)
- // {
- // while(dis9[i] != '\0')
- // {
- // lcd_wdat(dis9[i]); //顯示字符
- // i++;
- // }
- // }
- // else
- // {
- // while(dis0[i] != '\0')
- // {
- // lcd_wdat(dis0[i]); //顯示字符
- // i++;
- // }
- // }
- //}
- ///*******溫度檢測(cè)******/
- // /*********************/
- // /*********************/
- //void Temperature()
- //{
- //
- //
- // struct DHT12_Message dht11;
- // init_dht11();
- // dht11=get_data_dht11();
- // chun= (dht11.temperature_shi-48)*10+(dht11.temperature_ge-48);
- // if(chun>25)
- //
- // {
- // feng=0;
- // }
- // else
- // {
- // feng=1;
- //
- // }
- //}
- // /*****土壤濕度檢測(cè)******/
- // /*********************/
- // /*********************/
- //void Soil()
- //{
- //
- //
- // if(turang==0)
- // {
- // choushui=1;
- //
- // }
- // else
- // {
- // choushui=0;
- // }
- //}
- /*****光照檢測(cè)******/
- /*********************/
- /*********************/
- void Illumination()
- {
- if(guang==0)
- {
- zhao=1;
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
bishe1.7z
(25.49 KB, 下載次數(shù): 16)
2018-1-22 10:01 上傳
點(diǎn)擊文件名下載附件
|
評(píng)分
-
查看全部評(píng)分
|