找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 1882|回復(fù): 0
收起左側(cè)

基于單片機(jī)的智能花卉培養(yǎng)裝置源碼

[復(fù)制鏈接]
ID:278488 發(fā)表于 2018-1-22 10:02 | 顯示全部樓層 |閱讀模式
光照檢測(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)境因素的情況
0.jpg

單片機(jī)源程序:
  1. #include<reg52.h>
  2. #include "dht12.h"
  3. #include<intrins.h>
  4. #define uchar unsigned char
  5. #define uint unsigned int
  6. ///*TS12864A-3 端口定義*/
  7. //#define LCD_data  P0             //數(shù)據(jù)口
  8. //sbit LCD_RS  =  P3^4;            //寄存器選擇輸入
  9. //sbit LCD_RW  =  P3^5;            //液晶讀/寫控制
  10. //sbit LCD_EN  =  P3^6;            //液晶使能控制
  11. //sbit LCD_PSB =  P3^7;            //串/并方式控制

  12. ///*     89c52 端口定義*/
  13. //sbit turang=P1^3;
  14. //sbit choushui=P2^5;
  15. //sbit feng=P1^7;
  16. sbit guang=P2^1;
  17. sbit zhao=P2^2;
  18. sbit guangbu=P2^4;
  19. //uchar chun ;
  20. //uchar i;


  21. //uchar code dis1[] = {"智能花卉培養(yǎng)裝置"};
  22. //uchar code dis2[] = {"光照:"};
  23. //uchar code dis3[] = {"溫度:"};
  24. //uchar code dis4[] = {"濕度:"};
  25. //uchar code dis5[] = {"適宜"};
  26. //uchar code dis6[] = {"較暗"};
  27. //uchar code dis7[] = {"適宜"};
  28. //uchar code dis8[] = {"偏高"};
  29. //uchar code dis9[] = {"適宜"};
  30. //uchar code dis0[] = {"干燥"};
  31. //   

  32. //#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
  33. //uchar IRDIS[2];
  34. //uchar IRCOM[4];
  35. //void delay0(uchar x);  //x*0.14MS
  36. //void beep();
  37. //void  dataconv();
  38. //void lcd_pos(uchar X,uchar Y);  //確定顯示位置
  39. /*******************************************************************/
  40. /*                                                                 */
  41. /*  延時(shí)函數(shù)                                                       */
  42. /*                                                                 */
  43. /*******************************************************************/
  44. void delay(int ms)
  45. {
  46.     while(ms--)
  47.         {
  48.       uchar i;
  49.           for(i=0;i<250;i++)  
  50.            {
  51.             _nop_();                          
  52.                 _nop_();
  53.                 _nop_();
  54.                 _nop_();
  55.            }
  56.         }
  57. }               
  58. /*******************************************************************/
  59. /*                                                                 */
  60. /*檢查L(zhǎng)CD忙狀態(tài)                                                    */
  61. /*lcd_busy為1時(shí),忙,等待。lcd-busy為0時(shí),閑,可寫指令與數(shù)據(jù)。      */
  62. /*                                                                 */
  63. /*******************************************************************/
  64. //bit lcd_busy()
  65. // {                          
  66. //    bit result;
  67. //    LCD_RS = 0;
  68. //    LCD_RW = 1;
  69. //    LCD_EN = 1;
  70. //    delayNOP();
  71. //    result = (bit)(P0&0x80);
  72. //    LCD_EN = 0;
  73. //    return(result);
  74. // }
  75. ///*******************************************************************/
  76. ///*                                                                 */
  77. ///*寫指令數(shù)據(jù)到LCD                                                  */
  78. ///*RS=L,RW=L,E=高脈沖,D0-D7=指令碼。                             */
  79. ///*                                                                 */
  80. ///*******************************************************************/
  81. //void lcd_wcmd(uchar cmd)
  82. //{                          
  83. //   while(lcd_busy());
  84. //    LCD_RS = 0;
  85. //    LCD_RW = 0;
  86. //    LCD_EN = 0;
  87. //    _nop_();
  88. //    _nop_();
  89. //    P0 = cmd;
  90. //    delayNOP();
  91. //    LCD_EN = 1;
  92. //    delayNOP();
  93. //    LCD_EN = 0;  
  94. //}
  95. ///*******************************************************************/
  96. ///*                                                                 */
  97. ///*寫顯示數(shù)據(jù)到LCD                                                  */
  98. ///*RS=H,RW=L,E=高脈沖,D0-D7=數(shù)據(jù)。                               */
  99. ///*                                                                 */
  100. ///*******************************************************************/
  101. //void lcd_wdat(uchar dat)
  102. //{                          
  103. //   while(lcd_busy());
  104. //    LCD_RS = 1;
  105. //    LCD_RW = 0;
  106. //    LCD_EN = 0;
  107. //    P0 = dat;
  108. //    delayNOP();
  109. //    LCD_EN = 1;
  110. //    delayNOP();
  111. //    LCD_EN = 0;
  112. //}
  113. ///*******************************************************************/
  114. ///*                                                                 */
  115. ///*  LCD初始化設(shè)定                                                  */
  116. ///*                                                                 */
  117. ///*******************************************************************/
  118. //void lcd_init()
  119. //{

  120. //    LCD_PSB = 1;         //并口方式
  121. //   
  122. //    lcd_wcmd(0x34);      //擴(kuò)充指令操作
  123. //    delay(5);
  124. //    lcd_wcmd(0x30);      //基本指令操作
  125. //    delay(5);
  126. //    lcd_wcmd(0x0C);      //顯示開,關(guān)光標(biāo)
  127. //    delay(5);
  128. //    lcd_wcmd(0x01);      //清除LCD的顯示內(nèi)容
  129. //    delay(5);
  130. //}




  131. ///**************************************/
  132. // /*********************************************************/
  133. ///*                                                                                                                 */
  134. ///* 延時(shí)x*0.14ms子程序                                                                         */
  135. ///*                                                       */
  136. ///*********************************************************/

  137. //void delay0(uchar x)    //x*0.14MS
  138. //{
  139. //  uchar i;
  140. //  while(x--)
  141. // {
  142. //  for (i = 0; i<13; i++) {}
  143. // }
  144. //}
  145. ///*********************************************************/
  146. ///*                                                       */
  147. ///* 設(shè)定顯示位置                                          */
  148. ///*                                                       */
  149. ///*********************************************************/
  150. //void lcd_pos(uchar X,uchar Y)
  151. //{                          
  152. //   uchar  pos;
  153. //   if (X==0)
  154. //     {X=0x80;}
  155. //   else if (X==1)
  156. //     {X=0x90;}
  157. //   else if (X==2)
  158. //     {X=0x88;}
  159. //   else if (X==3)
  160. //     {X=0x98;}
  161. //   pos = X+Y ;  
  162. //   lcd_wcmd(pos);     //顯示地址
  163. //}







  164. //void Lcd()
  165. //{
  166. //         /*************************************/
  167. //         /********    顯示屏初始化     ********/
  168. //         /*************************************/
  169. //         /*************************************/   

  170. //    delay(10);                 //延時(shí)
  171. //    lcd_init();                //初始化LCD            
  172. //  
  173. //          /*************************************/
  174. //         /********       顯示屏        ********/
  175. //         /***************第一行*****************/
  176. //         /*************************************/

  177. //    lcd_pos(0,0);             //設(shè)置顯示位置為第一行的第1個(gè)字符
  178. //     i = 0;
  179. //    while(dis1[i] != '\0')
  180. //     {                         //顯示字符
  181. //       lcd_wdat(dis1[i]);
  182. //       i++;
  183. //     }

  184. //         /*************************************/
  185. //         /********       顯示屏        ********/
  186. //         /***************第二行*****************/
  187. //         /*************************************/


  188. //    lcd_pos(1,0);             //設(shè)置顯示位置為第二行的第1個(gè)字符
  189. //     i = 0;
  190. //    while(dis2[i] != '\0')
  191. //     {
  192. //       lcd_wdat(dis2[i]);      //顯示字符
  193. //       i++;
  194. //     }

  195. //           lcd_pos(1,3);                  //設(shè)置顯示位置為第二行的第4個(gè)字符
  196. //                        i = 0;

  197. //         if(guang==0)
  198. //           {
  199. //                        while(dis5[i] != '\0')
  200. //                        {
  201. //                                lcd_wdat(dis5[i]);      //顯示字符
  202. //                i++;
  203. //                        }
  204. //           }
  205. //           else
  206. //           {
  207. //                        while(dis6[i] != '\0')
  208. //                        {
  209. //                                lcd_wdat(dis6[i]);      //顯示字符
  210. //                i++;
  211. //                                }
  212. //           }

  213. //         /*************************************/
  214. //         /********       顯示屏        ********/
  215. //         /***************第三行*****************/
  216. //         /*************************************/
  217. //          lcd_pos(2,0);             //設(shè)置顯示位置為第三行的第1個(gè)字符
  218. //     i = 0;
  219. //         
  220. //    while(dis3[i] != '\0')
  221. //     {
  222. //       lcd_wdat(dis3[i]);      //顯示字符
  223. //       i++;
  224. //     }

  225. //                lcd_pos(2,3);             //設(shè)置顯示位置為第三行的第4個(gè)字符
  226. //        i = 0;


  227. //                if(chun<25)
  228. //           {
  229. //                        while(dis7[i] != '\0')
  230. //                        {
  231. //                                lcd_wdat(dis7[i]);      //顯示字符
  232. //                i++;
  233. //                        }
  234. //           }
  235. //           else
  236. //           {
  237. //                        while(dis8[i] != '\0')
  238. //                        {
  239. //                                lcd_wdat(dis8[i]);      //顯示字符
  240. //                i++;
  241. //                                }
  242. //           }


  243. //         /*************************************/
  244. //         /********       顯示屏        ********/
  245. //         /***************第四行*****************/
  246. //         /*************************************/
  247. //         lcd_pos(3,0);             //設(shè)置顯示位置為第四行的第1個(gè)字符
  248. //     i = 0;
  249. //     while(dis4[i] != '\0')
  250. //     {
  251. //       lcd_wdat(dis4[i]);      //顯示字符
  252. //       i++;
  253. //     }


  254. //          lcd_pos(3,3);             //設(shè)置顯示位置為第四行的第4個(gè)字符
  255. //     i = 0;
  256. //         if(turang==0)
  257. //           {
  258. //                        while(dis9[i] != '\0')
  259. //                        {
  260. //                                lcd_wdat(dis9[i]);      //顯示字符
  261. //                i++;
  262. //                        }
  263. //           }
  264. //           else
  265. //           {
  266. //                        while(dis0[i] != '\0')
  267. //                        {
  268. //                                lcd_wdat(dis0[i]);      //顯示字符
  269. //                i++;
  270. //                                }
  271. //           }


  272. //}



  273. ///*******溫度檢測(cè)******/
  274. //        /*********************/
  275. //                /*********************/


  276. //void Temperature()
  277. //{
  278. //          
  279. //       
  280. //           struct DHT12_Message dht11;
  281. //          init_dht11();
  282. //          dht11=get_data_dht11();
  283. //         chun= (dht11.temperature_shi-48)*10+(dht11.temperature_ge-48);
  284. //   if(chun>25)
  285. //   
  286. //   {
  287. //    feng=0;

  288. //   }                  
  289. //        else
  290. //        {
  291. //         feng=1;
  292. //       
  293. //        }
  294. //}



  295. //                 /*****土壤濕度檢測(cè)******/
  296. //        /*********************/
  297. //                /*********************/

  298. //void Soil()
  299. //{


  300. //     
  301. //          
  302. //                if(turang==0)
  303. //        {
  304. //          choushui=1;
  305. //          
  306. //        }                 
  307. //           else
  308. //        {
  309. //         choushui=0;
  310. //        }


  311. //}


  312.                   /*****光照檢測(cè)******/
  313.         /*********************/
  314.                 /*********************/

  315. void Illumination()
  316. {
  317.                   if(guang==0)
  318.                 {
  319.                         zhao=1;
  320. ……………………

  321. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
bishe1.7z (25.49 KB, 下載次數(shù): 16)



評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表