欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

51單片機(jī)+8266WiFi控制家用電器程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:840562 發(fā)表于 2020-11-8 14:46 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
只有程序,其他文件太大,無法發(fā)布

單片機(jī)源程序如下:
  1. #include "reg52.h"
  2. #include "uart.h"
  3. #include "stdio.h"

  4. #include "dht11.h"  
  5. #include "string.h"
  6. //管腳聲明
  7. unsigned char Timer0_count;
  8. unsigned char Timer0_miao;
  9. unsigned char miao1;
  10. unsigned char flag_init;
  11. unsigned char RsPoint;
  12. unsigned char xdata RsBuf[100];
  13. sbit LED2 = P1^2;        //燈光控制輸出
  14. sbit LED3 = P1^3;        //燈光控制輸出
  15. sbit LED4 = P1^4;        //燈光控制輸出
  16. sbit LED1 = P1^1;        //燈光控制輸出
  17. unsigned char Key_num;
  18. unsigned char Flag_rec;
  19. unsigned char Rec_stop;
  20. #include "lcd.h"




  21. void main()
  22. {
  23.         char *str2="AT+CIPSEND=14\r\n";
  24.         unsigned char i;

  25.         memset(&RsBuf[1],' ',18);
  26.     Uart_init();
  27.     lcd_init();
  28.         delay(3000);
  29.          SendString("+++");
  30.         delay(500);
  31.         SendString("+++\r\n");
  32.         delay(500);
  33. //        write_1602com(0xc0);
  34. //        for(i=0;i<16;i++)
  35. //        write_1602dat(RsBuf[i+2]);
  36.         Rec_stop=0;
  37.         
  38.         memset(&RsBuf[1],' ',18);
  39.         SendString("AT+CWMODE=1\r\n");
  40.         write_1602com(0x01);
  41.         write_string(0x80,"AT+CWMODE=1     ",0);
  42.         while(Rec_stop==0) ;
  43.         Rec_stop=0;
  44. //        write_1602com(0xc0);
  45. //        delay(1);
  46. //        for(i=0;i<2;i++)
  47. //        write_1602dat(RsBuf[i+2]);
  48.         delay(2000);

  49.         memset(&RsBuf[1],' ',18);
  50.         SendString("AT+RST\r\n");
  51.         write_1602com(0x01);
  52.     write_string(0x80,"AT+RST          ",0);
  53.         while(Rec_stop==0&&RsBuf[0]!='W');
  54.         Rec_stop=0;
  55. //        write_1602com(0xc0);
  56. //        for(i=0;i<16;i++)
  57. //        write_1602dat(RsBuf[i+2]);
  58.            delay(3000);

  59.           memset(&RsBuf[1],' ',18);
  60.     SendString("ATE0\r\n");
  61.         write_string(0x80,"ATE0            ",0);
  62.         write_string(0xc0,"                ",0);
  63.         while(Rec_stop==0) ;
  64.         Rec_stop=0;
  65. //        write_1602com(0xc0);
  66. //        delay(1);
  67. //        for(i=0;i<2;i++)
  68.         write_1602dat(RsBuf[i+2]);
  69.          delay(2000);

  70.            memset(&RsBuf[1],' ',18);
  71.         SendString("ATE0\r\n");
  72.         write_1602com(0x01);
  73.         write_string(0x80,"ATE0            ",0);
  74.         while(Rec_stop==0) ;
  75.         Rec_stop=0;
  76. //        write_1602com(0xc0);
  77. //        delay(1);
  78. //        for(i=0;i<2;i++)
  79. //        write_1602dat(RsBuf[i+2]);
  80.                  delay(2000);

  81.         memset(&RsBuf[1],' ',18);
  82.     SendString("AT+CIPMUX=0\r\n");
  83.         write_1602com(0x01);
  84.     write_string(0x80,"AT+CIPMUX=0      ",0);
  85.         while(Rec_stop==0);
  86.         Rec_stop=0;
  87. //        write_1602com(0xc0);
  88. //        for(i=0;i<2;i++)
  89. //        write_1602dat(RsBuf[i+2]);
  90.            delay(100);

  91.             memset(&RsBuf[1],' ',18);
  92.         SendString("AT+CIPSTART=\"TCP\",\"114.215.204.246\",9999\r\n");
  93.         write_1602com(0x01);
  94.     write_string(0x80,"AT+CISTART=TCP   ",0);
  95.         while(Rec_stop==0&&RsBuf[2]=='O');
  96.         Rec_stop=0;
  97. //        write_1602com(0xc0);
  98. //        for(i=0;i<2;i++)
  99. //        write_1602dat(RsBuf[i+2]);
  100.          delay(2000);


  101.             memset(&RsBuf[1],' ',18);
  102.         SendString("AT+CIPMODE=1\r\n");
  103.         write_1602com(0x01);
  104.     write_string(0x80,"AT+CIPMODE=1     ",0);
  105.         while(Rec_stop==0);
  106.         Rec_stop=0;
  107. //        write_1602com(0xc0);
  108. //        for(i=0;i<2;i++)
  109. //        write_1602dat(RsBuf[i+2]);
  110.          delay(2000);

  111.         RsPoint=0;
  112.         memset(&RsBuf[1],' ',18);
  113.     SendString("AT+CIPSEND\r\n");
  114.         write_1602com(0x01);
  115.     write_string(0x80,"AT+CIPSEND       ",0);
  116.         while(RsPoint==0);
  117. //        write_1602com(0xc0);
  118. //        for(i=0;i<16;i++)
  119. //        write_1602dat(RsBuf[i]);
  120.            delay(2000);
  121.         SendString("AT+CWJAP=\"wodewifi\",\"nidemima\"\r\n");                        
  122.          //在這里填入你的路由器名稱和密碼 分別替代wodewifi和 nidemima 雙引號和斜杠不能刪除
  123.         delay(5000);
  124.         
  125.          write_string(0x80,"Te:   C   Hu:  %",0);
  126.         write_string(0xc0,"STATUS:0000     ",0);
  127.         write_1602com(0x85);
  128.         write_1602dat(0xdf);

  129.         while(1)
  130.         {
  131.                   if(FlagStart==1)
  132.                 {
  133.                      TR0=0;
  134.              RH();
  135.                           FlagStart = 0;
  136.                          write_1602com(0x83);
  137.                          write_1602dat(temperature%100/10+0x30);
  138.                          write_1602dat(temperature%100%10+0x30);
  139.                          write_1602com(0x8d);
  140.                          write_1602dat(humidity%100/10+0x30);
  141.                          write_1602dat(humidity%100%10+0x30);
  142.                          SendString("{\"UN\":\"xxxxx@qqcom\",\"VER\":\"A1.1\",\"ID\":\"23502\",\"MAC\":\"18fe34f1cd9a\",\"TP\":\"");
  143.                          //784551388@qq.com是賬號          234100是ID
  144.                  SendASC(temperature%100/10+0x30);          //1
  145.                  SendASC(temperature%10+0x30);                //1
  146.                  SendString("\",\"HM\":\"");                   //  8
  147.                  SendASC(humidity%100/10+0x30);          //1
  148.                  SendASC(humidity%10+0x30);                //1
  149.                  SendString("\",\"SOC\":\"99\",\"RET\":\"1\"}\r\n");         
  150.                          TR0=1;
  151.                          Timer0_count=0;
  152.                          Timer0_miao=0;
  153.                 }
  154.          
  155.       
  156.                 write_1602com(0xc7);
  157.                 if(LED1)
  158.             write_1602dat('0');
  159.                 else
  160.                 write_1602dat('1');
  161.                 if(LED2)
  162.             write_1602dat('0');
  163.                 else
  164.                 write_1602dat('2');
  165.                 if(LED3)
  166.             write_1602dat('0');
  167.                 else
  168.                 write_1602dat('3');
  169.                 if(LED4)
  170.             write_1602dat('0');
  171.                 else
  172.                 write_1602dat('4');

  173.                 delay(100);
  174.         }

  175.    
  176. }

  177. //  通訊中斷接收程序   中斷函數(shù)無返回值
  178.   void uart_rx(void)  interrupt 4   //放在這里 和放在main()里面是一樣的
  179. {
  180.    
  181.         unsigned char dat;
  182.     if(RI)                         //是否接收中斷
  183.     {
  184.      RI=0;
  185.          dat = SBUF;
  186.          if(SBUF=='\r')
  187.          {
  188.            RsPoint=0;
  189.            Rec_stop=1;
  190.           }
  191.           RsBuf[RsPoint]=SBUF;
  192.           RsPoint++;
  193.          if(Flag_rec==1)
  194.          {
  195.                  switch (Key_num)
  196.                  {
  197.                   case 'A': if(dat=='0')LED1=0; else LED1=1;break;
  198.                   case 'B': if(dat=='0')LED2=0; else LED2=1; break;
  199.                   case 'C': if(dat=='0')LED3=0; else LED3=1; break;
  200.                   case 'D': if(dat=='0')LED4=0; else LED4=1; break;
  201.                  }
  202.                  Flag_rec=0;
  203.      }  
  204.          if(dat=='A'||dat=='B'||dat=='C'||dat=='D')
  205.          {
  206.           Flag_rec=1;
  207.           Key_num=dat;
  208.          }
  209.         }

  210. }

  211. void Timer0_ISR (void) interrupt 1 using 0
  212. {
  213.   TH0=0x4c;
  214.   TL0=0x00;
  215.   Timer0_count++;
  216.   if(Timer0_count>=20)
  217.   {
  218.    Timer0_count=0;
  219.    Timer0_miao++;

  220.    if(Timer0_miao>=2)
  221.    {
  222.     Timer0_miao=0;
  223.           FlagStart=1;
  224.    }
  225.   }
  226. }  
復(fù)制代碼

所有資料51hei提供下載:
1-程序 - 修改.zip (59.75 KB, 下載次數(shù): 14)


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

使用道具 舉報

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

本版積分規(guī)則

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

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

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