驱动蓝牙HC-05遇到的问题,,手机发送指令,开发板 接收到的数据能在LCD上显示出来,,但是用指令控制小灯亮灭就不好使了,,这是什么问题呢???求指教。。。。。。while(1)
{
key=KEY_Scan(0);
if(key==KEY_UP) //Çл»Ä£¿éÖ÷´ÓÉèÖÃ
{
key=HC05_Get_Role();
if(key!=0XFF)
{
key=!key; //״̬ȡ·´
if(key==0)HC05_Set_Cmd("AT+ROLE=0");
else HC05_Set_Cmd("AT+ROLE=1");
HC05_Role_Show();
HC05_Set_Cmd("AT+RESET"); //¸´Î»ATK-HC05Ä£¿é
}
}else if(key==KEY_RIGHT)
{
sendmask=!sendmask; //·¢ËÍ/Í£Ö¹·¢ËÍ
if(sendmask==0) LCD_Clear(0, 0, 240, 320, BACKGROUND); //Çå³ýÏÔʾ
}else delay_ms(10);
if(t==50)
{
if(sendmask) //¶¨Ê±·¢ËÍ
{
sprintf((char*)sendbuf,"ALIENTEK HC05 %d\r\n",sendcnt);
LCD_DispStr(70, 160, sendbuf, YELLOW);
u2_printf("ALIENTEK HC05 %d\r\n",sendcnt); //·¢Ë͵½À¶ÑÀÄ£¿é
sendcnt++;
if(sendcnt>99)sendcnt=0;
}
HC05_Sta_Show();
t=0;
LED0=!LED0;
}
if(USART2_RX_STA&0X8000) //½ÓÊÕµ½Ò»´ÎÊý¾ÝÁË
{
LCD_Clear(0, 0, 240, 320, BACKGROUND); //Çå³ýÏÔʾ
reclen=USART2_RX_STA&0X7FFF; //µÃµ½Êý¾Ý³¤¶È
USART2_RX_BUF[reclen]=0; //¼ÓÈë½áÊø·û
// if(reclen==9||reclen==8) //¿ØÖÆDS1¼ì²â
if(strcmp((const char*)USART2_RX_BUF,p)==0){LED1=0;} //´ò¿ªLED1
if(strcmp((const char*)USART2_RX_BUF,"guan")==0){LED1=1;}//¹Ø±ÕLED1
LCD_DispStr(200, 200, USART2_RX_BUF, YELLOW);
USART2_RX_STA=0;
}
t++;
}
} |