sbit BZ1=P1^4;
sbit BZ2=P1^5;
51單片機接收一大串語句如下
$SDALR,091313,001,A,A,BOTTOM LOST*77
$PFEC,SDmsi,1,2,M,K,F,200.0,1.57,4.00,0.00,0,1,1*1A
$PFEC,SDmsi,2,2,M,K,A,50.0,,4.00,0.00,0,1,1*1A
$SDDBT,5.1,f,1.5,M,0.8,F*0E
$SDDPT,1.5,0.0,10.5*65
$PFEC,xdr,FORE,200,1*63
$SDALR,091313,001,A,A,BOTTOM LOST*77
$PFEC,xdr,FORE,200,1*63
$PFEC,SDmsi,1,2,M,K,F,200.0,,4.00,0.00,0,1,1*1A
$PFEC,SDmsi,2,2,M,K,A,50.0,1.57,4.00,0.00,0,1,1*1A
$PFEC,SDmsi,2,2,M,K,A,50.0,2.57,4.00,0.00,0,1,1*1A
$SDDBT,5.1,f,1.5,M,0.8,F*0E
要求檢測收到的數據中這2句語句
$PFEC,SDmsi,1,2,M,K,F,200.0,1.57,4.00,0.00,0,1,1*1A
$PFEC,SDmsi,2,2,M,K,A,50.0,1.57,4.00,0.00,0,1,1*1A
并對這2個語句判斷,
$PFEC,SDmsi,1,2,M,K,F,200.0,1.57,4.00,0.00,0,1,1*1A
中有個,1.57, 如果這里的兩個逗號中間有數據(不一定是1,57,有可能其他值)就是寫BZ1=1,
沒有數據就BZ1=0
同理
$PFEC,SDmsi,2,2,M,K,A,50.0,1.57,4.00,0.00,0,1,1*1A
,1.57,這里的兩個逗號中間有數據(不一定是1,57,有可能其他值)就是寫BZ2=1,
沒有數據就BZ2=0
數據每秒鐘接收更新一次,