欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: stc89c52單片機串口通信代碼 [打印本頁]

作者: hahaso    時間: 2018-11-19 17:07
標題: stc89c52單片機串口通信代碼
電腦發送一個字符;
返回一個字符串
兩個按鍵對應不同字符串發送
#include<reg51.h>
#include<math.h>
#define u8 unsigned char
sbit k3=P3^2;
  sbit k4=P3^3;
   int x=2;
u8 shumaguang[19]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(int n)
{
while(n--);
}
void begin(void)                //初始函數
{
TMOD=0X20;
TH1=0XF3;
TL1=0XF3;
TR1=1;
PCON=0X80;
SCON=0X50;
ES=1;
IT1=1;
EX1=1;
  IT0=1;
EX0=1;
          EA=1;
}
void sendbyte(u8 ch) //發送單個字符
{
SBUF=ch;
while(!TI);
TI=0;
}
void sendstring(u8 *str)//發送字符串
{
while(*str)
{
sendbyte(*str++);
}
}
void sendstring2(u8 *str)//發送字符串  2
{
while(*str)
{
sendbyte(*str++);
}
}
void sendstring3(u8 *str)//發送字符串        3
{
while(*str)
{
sendbyte(*str++);
}
}
void sendstring4(u8 *str)//發送字符串        4
{
while(*str)
{
sendbyte(*str++);
}
}
void main(void) //主函數
{
        begin();
        P2=0x00;
        P3=0xff;
        delay(1000000);
sendstring4("welcome to west world!!!!!________________________________________\n");                     
    while(1)  ;
//        sendstring4("welcome to west world!!!!!\n");;
}
void rtinter(void) interrupt 4                //接受中斷
{
u8 receivedate;
receivedate=SBUF;
RI=0;
x=receivedate-'0';
P0=shumaguang[x];
sendstring("i have got it!!!buttom k3\n");
}
void outinter(void) interrupt 2           //外部中斷0
{
delay(100);
if(k4==0)
{sendstring2("i have a bottom\n");


}
}
void outinter2(void) interrupt 0                //外部中斷1
{
delay(100);
if(k3==0)
sendstring3("you send me a digit:\r");
sendbyte(x+'0');

}



作者: zhang1314hong    時間: 2018-11-25 22:48
謝謝分享




歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1