標(biāo)題: 51單片機(jī)檢測(cè)雨水的控制電路 附仿真原理圖和C程序 [打印本頁(yè)]

作者: 1131254814    時(shí)間: 2017-7-22 08:37
標(biāo)題: 51單片機(jī)檢測(cè)雨水的控制電路 附仿真原理圖和C程序
仿真需要自己添加程序,文件包內(nèi)附帶有程序

51單片機(jī) 單獨(dú)雨水檢測(cè)功能
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. /*

  2. 編寫(xiě)人:  鄧耀榮
  3. 編寫(xiě)日期:2017年7月15日

  4. IO口連接情況

  5. 1        LED1             40
  6. 2        LED2                 39
  7. 3        LED3                         38
  8. 4        LED4                         37
  9. 5        LED5                         36
  10. 6        LED6                         35
  11. 7        LED7                         34
  12. 8   LED8                         33
  13. 9                                 32
  14. 10                                 31
  15. 11                                 30
  16. 12        BB                         29
  17. 13                                 28
  18. 14                                 27
  19. 15                                 26
  20. 16                                 25          繼電器控制
  21. 17                                 24          水滴板
  22. 18                                 23
  23. 19                                 22
  24. 20                           21
  25. 此程序?qū)崿F(xiàn)的功能為水滴檢測(cè)控制繼電器吸合,以斷開(kāi)主水泵的線路,當(dāng)沒(méi)有雨水,則延時(shí)打開(kāi)主水泵的線路。
  26. */
  27. #include <reg52.h>
  28. sbit SETA = P2^3;
  29. sbit OT = P2^4;
  30. static unsigned char k = 0;
  31. sbit A1 = P1^0;
  32. sbit B1 = P1^1;
  33. sbit C1 = P1^2;
  34. sbit D1 = P1^3;
  35. sbit E1 = P1^4;
  36. sbit F1 = P1^5;
  37. sbit G1 = P1^6;
  38. sbit H1 = P1^7;
  39. sbit BB = P3^2;


  40. void Delay(unsigned long t)
  41. {
  42. while(--t);
  43. }

  44. void zhuangtai(void)
  45. {
  46.         H1 = 0;Delay(1000);BB = 0;
  47.         G1 = 0;Delay(1000);BB = 1;
  48.         F1 = 0;Delay(1000);BB = 0;
  49.         E1 = 0;Delay(1000);BB = 1;
  50.         D1 = 0;Delay(1000);BB = 0;
  51.         C1 = 0;Delay(1000);BB = 1;
  52.         B1 = 0;Delay(1000);
  53.         A:A1 = 0;Delay(9500);
  54.         A1 = 1;Delay(9500); if(SETA == 0){goto A;}
  55. }
  56. void d110ms(void){
  57.    unsigned char i,j,k;
  58.    for(i=6;i>0;i--)
  59.      for(j=18;j>0;j--)
  60.        for(k=248;k>0;k--);
  61. }

  62. void main (void)
  63. {
  64.         static unsigned char k = 0;
  65.         A1=B1=C1=D1=E1=F1=G1=H1=1;
  66.         OT = 0;
  67.         while(1)
  68.         {
  69.                  if(SETA == 0)
  70.                  {
  71.                          Delay(1000);
  72.                         if(SETA == 0)
  73.                          {
  74.                                     OT = 1;                                  
  75.                                    zhuangtai();
  76.                                    k = 255;
  77.                                    while(!SETA);
  78.                                    A1 = 0;
  79.                          }

  80.                  }
  81.                  if(k>0)
  82.                  {
  83.                          d110ms();
  84.                         k--;
  85.                           if(k == 232){A1 = 1;}
  86.                           if(k == 203){B1 = 1;}
  87.                           if(k == 174){C1 = 1;}
  88.                           if(k == 145){D1 = 1;}
  89.                           if(k == 116){E1 = 1;}
  90.                           if(k == 87) {F1 = 1;}
  91.                           if(k == 58) {G1 = 1;}
  92.                           if(k == 29) {H1 = 1;}
  93. ……………………

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

所有資料51hei提供下載:
STC 15F104W 單獨(dú)雨水檢測(cè)功能.zip (93.63 KB, 下載次數(shù): 28)



作者: 1131254814    時(shí)間: 2017-7-22 08:39
修正一下, 文中用到的單片機(jī)是STC89c52RC, 光耦是PC521

作者: zhangsp123    時(shí)間: 2017-8-30 17:02
下不了
作者: 賺錢(qián)買(mǎi)八爪魚(yú)    時(shí)間: 2019-12-3 09:59
樓主 ,這個(gè)能夠檢測(cè)雨量嘛





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1