单片机C语言程序设计:单片机向主机发送字符串

时间:2013-10-29来源:网络

/* 名称:单片机向主机发送字符串

说明:单片机按一定的时间间隔向主机

发送字符串,发送内容在虚拟终端显示。

*/

#includereg51.h>

#define uchar unsigned char

#define uint unsigned int

//延时

void DelayMS(uint ms)


{


uchar i;

while(ms--) for(i=0;i120;i++);

}

//向串口发送字符

void Putc_to_SerialPort(uchar c)

{

SBUF=c;

while(TI==0);

TI=0;

}

//向串口发送字符串

void Puts_to_SerialPort(uchar *s)

{

while(*s!='')

{

Putc_to_SerialPort(*s);

s++;

DelayMS(5);

}

}

1 2

关键词: 单片机 C语言 程序设计 字符串

加入微信
获取电子行业最新资讯
搜索微信公众号:EEPW

或用微信扫描左侧二维码

相关文章

查看电脑版