資源描述:
《51串口接收藍牙數(shù)據(jù)C程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、簡單51串口接受藍牙數(shù)據(jù)C程序-includeW#h3]Hj#GvgZ88579unsignedcharc_s[];電子園51單片機學習網(wǎng)(k/L#`}LFZunsignedcharf_s[]={0x0c,0x0d,0x0b,0x07,0x0c,0x0a,0x06,0x09,0x05,0x03};//發(fā)聲控制脈沖電子園51單片機學習網(wǎng)9QN#`t0Sh'Dm!T-MQunsignedchari=0;電子園51單片機學習網(wǎng)+{FJl"Tunsignedcharp_c;(V#y(sXk2fw88579voi
2、ddelay(unsignedinta){3_&K+sa!{E88579{cSnw~W88579?unsignedinti;電子園51單片機學習網(wǎng)8`+g9?8n$M6L;jL6~?while(a--){8f*x0q;f*fFg#@88579?for(i=0;i<125;i++)1cb9K:P{G88579?{}電子園51單片機學習網(wǎng).vx(HkTK?}電子園51單片機學習網(wǎng)}JtQ7YZr*R
3、WC}%C?fvc+U83}'TYrT(~88579voidchkou()inter
4、rupt4{??????//中斷處理0s}^1d/r7X&GG/I88579?if(p_c==0){?????????????????????//判數(shù)字標志位電子園51單片機學習網(wǎng)4Yfjv/W?if(RI){???????????????????????//判中斷je)Y-nq1[w]88579??RI=0;????????????????????????//電子園51單片機學習網(wǎng)F&D`ezt3AnxVN+IY??c_s[0]=SBUF;?????????????????//讀數(shù)a0e
5、r(uDjK8
6、8579??if(c_s[0]==0x43){????????????//判CE4dxC~)L:WoOWq88579???p_c=1;@m,
7、L9cOv*c]+o88579???}W.vV0Z6B(t]88579??else{.GRrgv88579???p_c=0;電子園51單片機學習網(wǎng),O;AbD6kAW4@T??}電子園51單片機學習網(wǎng)"H1qPao?}~,Z%~hwEjW88579?}電子園51單片機學習網(wǎng)r2C9XIN*?else{電子園51單片機學習網(wǎng)
8、zWD2
9、5d+[V?
10、u??if(RI){電子園51單片機學習網(wǎng)QO%Qq3{b1@4KW(Bl7[R7o??RI=0;電子園51單片機學習網(wǎng)}(PyX5EzMH??c_s[i]=SBUF;uv9M#vS/k!a88579??while(!RI);*G(T'o[@2
11、z2b88579??RI=0;電子園51單片機學習網(wǎng)0w2Kg+}G}??if(c_s[i]==0x0d){?????????????//判D:e?_}3_88579???EA=0;????????????????????
12、??//關(guān)中斷電子園51單片機學習網(wǎng)`I6n!r4J%fA???p_c=0;????????????????????????電子園51單片機學習網(wǎng),Dnqc0B(a???panduan();電子園51單片機學習網(wǎng)0BZ7Vg5r"gB???EA=1;6^8u.r;jlt:Idy88579???}m5k8V;wfL88579??else{8aLQ?c}p88579???i++;電子園51單片機學習網(wǎng)&E'V8vb?T2G??}電子園51單片機學習網(wǎng)I_'?V%S&k8fC?})
13、@7sg6X8
14、8579?}lj.S5ciO&S88579}電子園51單片機學習網(wǎng)MG'~!vl+Y#dyr!R^3bik88579panduan(){???????????????????????//發(fā)聲程序電子園51單片機學習網(wǎng)&
15、+b/OM7{o%`?unsignedchara,b;電子園51單片機學習網(wǎng)9?kXv[ZXOL?for(a=0;a電子園51單片機學習網(wǎng)"w4qT`2]?b=c_s[a];*pH'qj,~!D88579?P1=f_s[b];電子園51單片機學習網(wǎng)6WLG7k0Z$e?dela
16、y(10000);???????????????????//大概延時/p7nF"qr{)o88579?delay(10000);電子園51單片機學習網(wǎng)lYK)wWeC?}%EoW1tT4