找到方法了 !!!使用转义字符!!
下边是修改的代码供大家参考
谢谢 老师的回答 !非常感谢!
#include <reg52.h>
#include <stdio.h>
sbit Mr0 = P1^0;
sbit Ml0 = P1^1;
sbit Mr1 = P1^2;
sbit Ml1 = P1^3;
#define uint unsigned int
#define uchar unsigned char
#define card_go {Mr0=0,Ml0=1,Mr1=0,Ml1=1;}
#define card_back {Mr0=1,Ml0=0,Mr1=1,Ml1=0;}
#define Left_card_go {Mr0=0,Ml0=1,Mr1=1,Ml1=0;}
#define Right_card_go { Mr0=1,Ml0=0,Mr1=0,Ml1=1;}
#define stop_card { Mr0=0,Ml0=0,Mr1=0,Ml1=0;}
#define up 'A'
#define down 'B'
#define left 'C'
#define right 'D'
#define stop 'F'
uchar i=0;
uchar dat=0;
uchar buff[14]=0;
bit flag_REC=0;
bit flag =0;
void sint() interrupt 4
{
if(RI)
{
RI=0;
dat=SBUF;
if(dat=='+'&&(i==0))
{
buff[i]=dat;
flag=1;
}
else
if(flag==1)
{
i++;
buff[i]=dat;
if(i>=14)
{i=0;flag=0;flag_REC=1 ;}
}
}
}
void delay(uint z)
{
uint x,y;
for(x = z; x > 0; x--)
for(y = 114; y > 0 ; y--);
}
void sennd()
{
TI = 1;
puts("AT+CIPMUX=1\r");
while(!TI);
delay(2000);
puts("AT+CIPSTART=0,\"TCP\",\"10.201.134.152\",36594\r");
while(!TI);
TI = 0;
delay(3000);
}
void UART_INIT()
{
SM0 = 0; SM1 = 1;
REN = 1;
EA = 1;
ES = 1;
TMOD = 0x20;
TH1 = 0xfd;
TL1 = 0xfd;
TR1 = 1;
}
void main()
{
UART_INIT();
EA = 0;
delay(2000);
sennd();
EA = 1;
while(1)
{
if(flag_REC==1)
{
flag_REC=0;
if(buff[0]=='+'&&buff[1]=='I')
switch(buff[10])
{
case up : card_go; P1 = ~P1; break;
case down : card_back; break;
case left : Left_card_go; break;
case right : Right_card_go; break;
case stop : stop_card; break;
}
}
}
}
|