欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機控制ESP8266的代碼問題
[打印本頁]
作者:
1061897836
時間:
2018-11-16 21:02
標題:
單片機控制ESP8266的代碼問題
正在學ESP8266或者已經會了的壇友們,想請問這個代碼有問題嗎?
模塊和單片機連接沒有什么問題,但是執行代碼后,給ESP發送1,LED只會閃爍一下,添加了延時也這樣,而且也收不到ESP發送的打開和關閉,是什么原因呢?
作者:
1061897836
時間:
2018-11-16 21:13
發錯了代碼,這個才是
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit led=P1^0;
uchar Receive,i;
uint n;
uchar Recive_table[15];
void ms_delay(uint t)
{
uint i,j;
for(i=t;i>0;i--)
for(j=110;j>0;j--);
}
void us_delay(uchar t)
{
while(t--);
}
void Uart_Init()
{
SCON=0x50;
PCON=0x00;
TMOD=0x21;
TH1=0xfd;
TL1=0xfd;
EA=1;
ES=1;
TR1=1;
}
void Send_Uart(uchar value)
{
ES=0;
TI=0;
SBUF=value;
while(TI==0);
TI=0;
ES=1;
}
void ESP8266_Set(uchar *puf)
{
while(*puf!='\0')
{
Send_Uart(*puf);
us_delay(5);
puf++;
}
us_delay(5);
Send_Uart('\r');
us_delay(5);
Send_Uart('\n');
}
void ESP8266_Sent(uchar *puf)
{
ESP8266_Set("AT+CIPSEND=0,2");
while(*puf!='\0')
{
Send_Uart(*puf);
us_delay(5);
puf++;
}
us_delay(5);
Send_Uart('\n');
ms_delay(10);
}
void main()
{
Uart_Init();
ms_delay(500);
led=0;
ESP8266_Set("AT+CWMODE=2");
ms_delay(500);
ESP8266_Set("AT+CIOBAUD=9600");
ms_delay(500);
ESP8266_Set("AT+CWSAP=\"hello\",\"12345678\",1,3");
ms_delay(500);
ESP8266_Set("AT+CIPMUX=1");
ms_delay(500);
ESP8266_Set("AT+CIPSERVER=1,8000");
ms_delay(500);
ESP8266_Set("AT+CIPSTO=0");
ES=1;
while(1)
{
if((Recive_table[0]=='+')&&(Recive_table[1]=='I')&&(Recive_table[2]=='P'))
{
if((Recive_table[3]=='D')&&(Recive_table[6]==','))
{
if(Recive_table[9]=='0')
{
led=0;
ESP8266_Sent("OFF");
}
else if(Recive_table[9]=='1')
{
led=1;
ESP8266_Sent("ON");
}
}
}
}
}
void Uart_Interrupt() interrupt 4
{
static uchar i=0;
if(RI==1)
{
RI=0;
Receive=SBUF;
Recive_table[i]=Receive;
if((Recive_table[i]=='\n'))
{
i=0;
}
else i++;
}
else TI=0;
}
復制代碼
作者:
小貓貓愛吃魚
時間:
2018-11-16 22:15
你的代碼能編譯通過?
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1