紅色按鍵、綠色按鍵、光感能執(zhí)行,天線無法接收到信號執(zhí)行后面程序,天線通訊地址、天線損壞問題都用排除法排除,請大咖幫忙指點一下問題在哪里,萬分感謝!!!
while(1)
{
if(k==0)
{
if(KEY0==0) //綠色按鍵
{
if(G3!=0) //如果回收終端頂部不被遮擋,按壓綠色按鍵后啟動
{
J1=0;
f=0;
}
}
if(KEY1==0) //按下紅色按鈕,電機停止轉動
{
J1=1;
}
if(G3==0) //如果回收終端頂部光感感應到線纜就停止
{
J1=1;
f=1;
}
}
}
delay_ms(10);
RX_Mode();
if(NRF24L01_RxPacket(tmp_buf)==0)//一旦接收到信息,則顯示出來
{
TX_Mode();
if(tmp_buf[0]==5)
{
if(tmp_buf[1]==1) //51為機臺號碼
{
if(tmp_buf[2]==1)
{
if(tmp_buf[3]==4)///14為收線的驗證碼
{
k=1;
J1=0;
delay_ms(5000); //改停止時間
J1=1;
a=1; //標志位
delay_ms(10);
tmp_buf[0]=0;
tmp_buf[1]=0;
tmp_buf[2]=0;
tmp_buf[3]=0; //接收到掃卡收線信號后,回收終端電機轉動,將線纜傳送到物流車
}
}
}
}
}
if(a==1)
{
delay_ms(5000);
J1=0;
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
}
if(G3!=0)
{
delay_ms(500);
J1=1;
} //回收終端收線防錯,依靠時間停止跟感應停止將傳送帶中部線纜輸送至回收終端頂部
else
{
delay_ms(600);
J1=1;
}
a=0;
}
if(KEY1==0)
{
J1=1;
}
}
|