找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 9555|回復(fù): 10
打印 上一主題 下一主題
收起左側(cè)

基于51單片機的智能窗簾控制系統(tǒng)Proteus仿真程序

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:721091 發(fā)表于 2020-6-1 17:19 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
自己做的設(shè)計,能夠手動開關(guān)窗簾,根據(jù)光照與溫度自動開關(guān)窗簾,有溫控和光控模式,每個模式都有一個按鈕進行控制。窗簾的開關(guān)是根據(jù)電機的狀態(tài)來判斷的,比如0是打開,130左右是關(guān)閉。
本人大二,設(shè)計上可能還有改善的空間,但給師傅看時是非常完善,沒有錯誤的,歡迎交流,請多指教~

仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. #include<reg52.h>                   //頭文件
  2. #include"LCD1602.h"
  3. #include"ADC0832.h"
  4. #include"28BYJ48.h"
  5. #include"DS18B20.h"

  6. #define uchar unsigned char

  7. sbit k1 = P1^0;
  8. sbit k2 = P1^1;
  9. sbit k3 = P1^2;
  10. sbit k4 = P1^3;

  11. //全局變量
  12. uchar light=0,temp=0;
  13. int flag=0,z=0,f=0;
  14. int q=0;
  15. int j=0,k=0;
  16. int count=0,flag1=0;
  17. int Time;
  18. int mode=0;

  19. void delay(int x)
  20. {
  21.         int i;
  22.         while(x--)
  23.         for(i=10;i>0;i--);
  24. }

  25. void auto_control_motor(uchar dat)
  26. {
  27.         if(Time < dat)
  28.         {
  29.                 Time++;
  30.                 motor_z();
  31.         }
  32.         else if(Time == dat) motor_s();
  33.         else
  34.         {
  35.                 Time--;
  36.                 motor_f();
  37.         }
  38. }

  39. void light_state_control()
  40. {
  41.         if(light<0)                                                        flag = -1;
  42.         if(light>=0 && light<35)                        flag = 0;
  43.         else if(light>35 && light<75)                flag = 1;
  44.         else                                                                flag = 2;

  45.         switch(flag){
  46.                 case -1:        auto_control_motor(0);
  47.                         break;
  48.                 case  0:        auto_control_motor(0);
  49.                         break;
  50.                 case  1:        auto_control_motor(10);
  51.                         break;
  52.                 case  2:        auto_control_motor(30);
  53.                         break;
  54.                 }
  55. }

  56. void temp_state_control()
  57. {
  58.         if(current<0)                                                        flag = 0;
  59.         if(current>15 && current<=25)                        flag = 0;
  60.         else if(current == 15)                                        motor_s();                                         //特殊情況
  61.         else if(current>25 && current<35)                flag = 1;
  62.         else                                                                        flag = 2;

  63.         switch(flag){
  64.                 case -1:delay(10000);
  65.                         break;
  66.                 case  0:        auto_control_motor(0);
  67.                         break;
  68.                 case  1:        auto_control_motor(14);
  69.                         break;
  70.                 case  2:        auto_control_motor(14);
  71.                         break;
  72.                 }
  73. }

  74. void curtain_state_control()
  75. {
  76.         if((light>=0 && light<35))                        flag = 0;
  77.         else if((light>35 && light<75))                flag = 1;
  78.         else                                                                flag = 2;
  79.         
  80.         switch(flag){
  81.         case  0:        
  82.                                 lcd1602_write_character(12, 3, "on  ");
  83.                                 lcd1602_write_character(12, 4, "low ");
  84.                 break;
  85.         case  1:        
  86.                                 lcd1602_write_character(12, 3, "half");
  87.                                 lcd1602_write_character(12, 4, "mid ");
  88.                 break;
  89.         case  2:        
  90.                                 lcd1602_write_character(12, 3, "off ");
  91.                                 lcd1602_write_character(12, 4, "high");
  92.                 break;
  93.         }        
  94. }


  95. void main(void)
  96. {

  97.         delay(100);
  98.         ReadTemperature();
  99.         delay(100);
  100.         LCD_init();
  101.         ADC0832_read(0);
  102.         ADC0832_read(0);
  103.         lcd1602_write_character(0, 1, "Light  :");
  104.         lcd1602_write_character(0, 2, "Temp   :");
  105.            lcd1602_write_character(0, 3, "Cutain :");
  106.         lcd1602_write_character(0, 4, "Level  :");
  107.         while(1)
  108.         {               
  109.                 if(k1 == 0)                mode = 1;
  110.                 if(k2 == 0)                mode = 2;
  111.                 if(k3 == 0)                mode = 3;
  112.                 if(k4 == 0)                mode = 4;

  113.                 if(mode==1)
  114.                 {
  115.                         light=ADC0832_read(0);                                                                //讀取AD值
  116.                         light=light*100/255;                                                                //轉(zhuǎn)換為光強
  117.                
  118.                         LCD_disp_char(12, 1, ASCII[light/100]);
  119.                         LCD_disp_char(13,1,ASCII[light%100/10]);
  120.                         LCD_disp_char(14,1,ASCII[light%10]);
  121.                         //窗簾狀態(tài)管理
  122.                         light_state_control();
  123.                         curtain_state_control();
  124.                 }
  125. //-------------------------------溫控模式--------------------------------------
  126.                 if(mode==2)
  127.                 {
  128.                         DS_read_temperature();
  129.                         display_temperature();
  130.                           temp_state_control();
  131.                         if(current>15 && current<=25) lcd1602_write_character(12, 3, "on  ");
  132.                         else lcd1602_write_character(12, 3, "off ");  
  133. ……………………

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

所有資料51hei提供下載:
智能窗簾.zip (84.95 KB, 下載次數(shù): 365)

評分

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

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏12 分享淘帖 頂2 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:791661 發(fā)表于 2020-6-29 14:23 | 只看該作者
void auto_control_motor(uchar dat)
{
        if(Time < dat)
        {
                Time++;
                motor_z();
        }
        else if(Time == dat) motor_s();
        else
        {
                Time--;
                motor_f();
        }
}
這一段的Time有數(shù)值嗎
回復(fù)

使用道具 舉報

板凳
ID:794694 發(fā)表于 2020-7-1 14:07 來自手機 | 只看該作者
我到protues仿真不成功,為什么

5f5e8081fd5fa63.jpg (1.6 MB, 下載次數(shù): 205)

5f5e8081fd5fa63.jpg
回復(fù)

使用道具 舉報

地板
ID:794590 發(fā)表于 2020-7-1 15:32 | 只看該作者
乃萬 發(fā)表于 2020-6-29 14:23
void auto_control_motor(uchar dat)
{
        if(Time < dat)

全局變量有默認(rèn)值
回復(fù)

使用道具 舉報

5#
ID:328014 發(fā)表于 2020-7-2 03:47 | 只看該作者
208314763 發(fā)表于 2020-7-1 14:07
我到protues仿真不成功,為什么

你這個是安裝有問題.我剛下載測試的時候也是報錯,不過不是你這個錯誤,是顯示External model DLL "ADC083X.DLL" not found. GLE=0x000036B1.
后來我從http://www.torrancerestoration.com/bbs/dpj-56637-1.html  這里下載了adc083x.dll 到模塊目錄就搞定了
我是安裝的Proteus仿真8.8版本

效果如下圖:

51hei.png (32.39 KB, 下載次數(shù): 225)

51hei.png
回復(fù)

使用道具 舉報

6#
ID:796538 發(fā)表于 2020-7-5 07:47 | 只看該作者
51hei團團 發(fā)表于 2020-7-2 03:47
你這個是安裝有問題.我剛下載測試的時候也是報錯,不過不是你這個錯誤,是顯示External model DLL "ADC083X ...

怎么安裝這個文件包呢,我百度看直接拖進去,我拖進去了還是不好使,還是會顯示adc083x
回復(fù)

使用道具 舉報

7#
ID:897661 發(fā)表于 2021-3-30 15:39 | 只看該作者
可以遙控嗎
回復(fù)

使用道具 舉報

8#
ID:910315 發(fā)表于 2021-4-26 10:00 | 只看該作者
51hei團團 發(fā)表于 2020-7-2 03:47
你這個是安裝有問題.我剛下載測試的時候也是報錯,不過不是你這個錯誤,是顯示External model DLL "ADC083X ...

你好  附件在哪找的
回復(fù)

使用道具 舉報

9#
ID:839752 發(fā)表于 2021-5-7 19:45 | 只看該作者
你好,有具體的各個模塊的講解嗎,比如光敏檢測模塊的數(shù)據(jù)傳輸,單片機初學(xué)者,希望得到你的答復(fù)
回復(fù)

使用道具 舉報

10#
ID:721091 發(fā)表于 2021-5-25 08:52 | 只看該作者

沒做遙控
回復(fù)

使用道具 舉報

11#
ID:721091 發(fā)表于 2021-5-25 08:53 | 只看該作者
TTTZW 發(fā)表于 2021-5-7 19:45
你好,有具體的各個模塊的講解嗎,比如光敏檢測模塊的數(shù)據(jù)傳輸,單片機初學(xué)者,希望得到你的答復(fù)

時間太久遠(yuǎn)了,現(xiàn)在不做單片機,這些資料沒有了嗷 不好意思
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

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

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

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