找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3065|回复: 0
打印 上一主题 下一主题
收起左侧

新唐M451单片机智能家居室内WIFI报警系统设计源码与资料

[复制链接]
跳转到指定楼层
楼主
很好的资源。


新唐M451单片机源程序如下:

  1. #include <stdio.h>
  2. #include "M451Series.h"
  3. #include "nuclk.h"
  4. #include "nuadc.h"
  5. #include "nuuart.h"
  6. #include "nugpio.h"
  7. unsigned char dianji=0,i=0;
  8. unsigned char tx_buf[101],rx_buf[100],key[3];
  9. long int timemain=0;
  10. unsigned int adc=0;
  11. void delay_ms(long unsigned int tem)
  12. {int temp;
  13.         while(tem--)
  14.         {temp=8000;
  15.         while(temp--)if(temp%5)PD4=1;
  16.         else PD4=0;}
  17. }
  18. int main()
  19. {

  20.    
  21.     SYS_Init();
  22.     /* Init UART0 to 115200-8n1 for print message */
  23.     UART0_Init(115200);
  24.           Input_init();
  25.                 Output_init();
  26.     Open_ADC_Knob();
  27.     printf("\n");
  28.     printf("Simple Demo Code\n\n");

  29.     printf("Please Input Any Key\n\n");
  30. //   UART_Write(UART0, chh, 5);
  31.         for(i=0;i<100;i++)tx_buf[i]=255;
  32.        
  33.         printf("AT+CIPSTART=\"TCP\",\"172.18.171.30\",8080\n\r\0");
  34.         delay_ms(700);
  35. //        printf("AT+CIPMODE=1\r\n");
  36.                 delay_ms(700);
  37. //        printf("AT+CIPSEND\r\n");
  38.     tx_buf[0]='8';
  39.     tx_buf[1]='9';
  40.                 tx_buf[100]=0;
  41.     rx_buf[7]=48;
  42.     while(1)
  43.                 {               
  44.                            if(timemain%300==0)//adc
  45.                {
  46.                       adc=Get_ADC_Knob()*330/4096;
  47.                 tx_buf[2]=adc>>8;tx_buf[3]=adc&0xff;
  48.                                          if(tx_buf[2]==0)tx_buf[2]=255;
  49.                }
  50.                                  
  51.     if(timemain%10==0)//
  52.                 {
  53.                           key[0]=  KEY3;// ?gpio 13   p4 ???
  54.                     key[1]= KEY4;// ?gpio 22   p15  ???
  55.                     if(key[0]==0)  tx_buf[5]=0x30;
  56.                     else    tx_buf[5]=0x31;
  57.                     if(key[1]==0)  tx_buf[4]=0x30;
  58.                      else    tx_buf[4]=0x31;
  59.                  }
  60.     if(timemain%30==0)//io??
  61.           {  
  62.               if(rx_buf[7]==0x31) LED0=1,tx_buf[6]=0x31;
  63.               else    if(rx_buf[7]==0x30&&dianji==0) LED0=0,tx_buf[6]=0x30;
  64.                     if (adc>100)LED0=1,tx_buf[6]=0x31,dianji=1;
  65.                     if(adc<60&&dianji==1)LED0=0,tx_buf[6]=0x30,dianji=0;
  66.           }

  67.    if(timemain%500==0)
  68.             {                printf("AT+CIPSTART=\"TCP\",\"172.18.171.30\",8080\n\r\0");
  69.                                         delay_ms(10);
  70.                                 printf("AT+CIPSEND=100\r\0");
  71.                                 delay_ms(10);
  72.                         //         UART_Write(UART0, tx_buf, 100);
  73.                                 printf("%s",tx_buf);delay_ms(10);
  74.                                
  75.                 //                UART_Read(UART0, rx_buf, 100);
  76.                                
  77.                         }//wifi??

  78. //  BsdTcpClient(PORT_NUM );//wifi??

  79. timemain++;delay_ms(1);
  80. if(timemain%100000==0) ;
  81. if(timemain%200000==0) ;
  82. if(timemain>=1000000) timemain=0;
  83.                
  84.                 }

  85. }

  86. /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
复制代码

所有资料51hei提供下载:
28 智能家居室内WIFI报警系统设计.zip (8.31 MB, 下载次数: 57)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表