标签:style blog color ar for 数据 div sp log
1 #include "reg52.h" 2 #include "intrins.h" 3 #define uchar unsigned char 4 #define uint unsigned int 5 6 void delay( uchar x) 7 { 8 uint y; 9 for (; x > 0 ; x-- ) 10 for( y=500 ;y>0;y--); 11 12 13 } 14 15 uchar a;//接收蓝牙模块发送的数据 16 17 void main() 18 { 19 uchar b=0x7f; 20 uchar bb = 0xcf; 21 uchar bbb = 0xef; 22 TMOD=0x20;//定时器1工作方式2,8位自动重装 23 TH1=0xFd; //11.0592M晶振,9600波特率 24 TL1=0xFd; 25 SCON=0x50;//串口方式1 SM0 SM1 01 允许接收 26 PCON=0x00;//SMOD=0 16分频 27 TR1=1;//打开定时器1 28 ES=1;//打开串口中断 29 EA=1;//开总中断 30 while(1) 31 { 32 if(a== ‘A‘) 33 { 34 delay(1000); 35 P1=b; 36 } 37 else if(a== ‘B‘) 38 { 39 delay(1000); 40 P1 = bb; 41 } 42 else 43 P1 = bbb; 44 } 45 46 } 47 48 void serial() interrupt 4 //中断子函数 49 { 50 RI=0; 51 a = SBUF; 52 }
标签:style blog color ar for 数据 div sp log
原文地址:http://www.cnblogs.com/chris-cp/p/3963524.html