Error[8]: Undefined offset: 260, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

#include 
#include "intrins.h"
#include "string.h"
char uart_dat[10];
int uart_temp=0;
sbit ledOne=P3^7;
sbit ledTwo=P3^6;
/**
*函数名称:UartInit
*函数功能:波特率初始化
*备 注:
*/
void UartInit(void)		//9600bps@11.0592MHz
{
	PCON &= 0x7F;		//波特率不倍速
	SCON = 0x50;		//8位数据,可变波特率
	AUXR &= 0xBF;		//定时器时钟12T模式
	AUXR &= 0xFE;		//串口1选择定时器1为波特率发生器
	TMOD &= 0x0F;		//设置定时器模式
	TMOD |= 0x20;		//设置定时器模式
	TL1 = 0xFD;		//设置定时初始值
	TH1 = 0xFD;		//设置定时重载值
	ET1 = 0;		//禁止定时器%d中断
	TR1 = 1;		//定时器1开始计时
	ES=1;
	EA=1;
}
/**
*函数名称:uartService
*函数功能:串口服务函数
*备 注:
*/
void uartService() interrupt 4
{
	if(RI==1)
	{
		uart_dat[uart_temp]=SBUF;
		uart_temp++;
		RI=0;
	}
}
/**
*函数名称:sendDate
*函数功能:发送一个字节
*备 注:
*/
void sendDate(unsigned char dat)
{
	SBUF=dat;
	while(TI==0);
	TI=0;
}
/**
*函数名称:sendString
*函数功能:发送一个字符串
*备 注:
*/
void sendString(unsigned char *str)
{
	while(*str!=')'sendDate
	{
		(*++str);}
	}
/**
*函数名称:judgeInformation
*函数功能:判断接收到的数据,同时对LED1和LED2 *** 作
*备 注:
*/
void
judgeInformation ()if
{
	(==uart_temp1)=
	{
		uart_temp0;if
		(strcmp(,uart_dat"A")==0)=
		{
			ledOne0;sendString
			("L1 is open");}
		if
		(strcmp(,uart_dat"B")==0)=
		{
			ledOne1;sendString
			("L1 is close");}
		if
		(strcmp(,uart_dat"C")==0)=
		{
			ledTwo0;sendString
			("L2 is open");}
		if
		(strcmp(,uart_dat"D")==0)=
		{
			ledTwo1;sendString
			("L2 is close");}
		}
	}
/**
*函数名称:main
*函数功能:主函数
*备 注:
*/
void
main ()UartInit
{
	();sendString
	("welcome:\r\n");while
	(1)judgeInformation
	{
		();}
	}
[+++]
)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 29, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
基于HC-08蓝牙模块的蓝牙通讯_C_内存溢出

基于HC-08蓝牙模块的蓝牙通讯

基于HC-08蓝牙模块的蓝牙通讯,第1张

  •   RXD接TXD,TXD接RXD。通过手机的蓝牙助手可以完成亮灭LED1和LED2的 *** 作
    
  •   当发送A时,LED1亮。发送B时,LED1灭。当发送C时,LED2亮,当发送D时,LED2灭
    
  •   使用的STC89C52RC单片机
    
#include 
#include "intrins.h"
#include "string.h"
char uart_dat[10];
int uart_temp=0;
sbit ledOne=P3^7;
sbit ledTwo=P3^6;
/**
*函数名称:UartInit
*函数功能:波特率初始化
*备 注:
*/
void UartInit(void)		//9600bps@11.0592MHz
{
	PCON &= 0x7F;		//波特率不倍速
	SCON = 0x50;		//8位数据,可变波特率
	AUXR &= 0xBF;		//定时器时钟12T模式
	AUXR &= 0xFE;		//串口1选择定时器1为波特率发生器
	TMOD &= 0x0F;		//设置定时器模式
	TMOD |= 0x20;		//设置定时器模式
	TL1 = 0xFD;		//设置定时初始值
	TH1 = 0xFD;		//设置定时重载值
	ET1 = 0;		//禁止定时器%d中断
	TR1 = 1;		//定时器1开始计时
	ES=1;
	EA=1;
}
/**
*函数名称:uartService
*函数功能:串口服务函数
*备 注:
*/
void uartService() interrupt 4
{
	if(RI==1)
	{
		uart_dat[uart_temp]=SBUF;
		uart_temp++;
		RI=0;
	}
}
/**
*函数名称:sendDate
*函数功能:发送一个字节
*备 注:
*/
void sendDate(unsigned char dat)
{
	SBUF=dat;
	while(TI==0);
	TI=0;
}
/**
*函数名称:sendString
*函数功能:发送一个字符串
*备 注:
*/
void sendString(unsigned char *str)
{
	while(*str!=')'sendDate
	{
		(*++str);}
	}
/**
*函数名称:judgeInformation
*函数功能:判断接收到的数据,同时对LED1和LED2 *** 作
*备 注:
*/
void
judgeInformation ()if
{
	(==uart_temp1)=
	{
		uart_temp0;if
		(strcmp(,uart_dat"A")==0)=
		{
			ledOne0;sendString
			("L1 is open");}
		if
		(strcmp(,uart_dat"B")==0)=
		{
			ledOne1;sendString
			("L1 is close");}
		if
		(strcmp(,uart_dat"C")==0)=
		{
			ledTwo0;sendString
			("L2 is open");}
		if
		(strcmp(,uart_dat"D")==0)=
		{
			ledTwo1;sendString
			("L2 is close");}
		}
	}
/**
*函数名称:main
*函数功能:主函数
*备 注:
*/
void
main ()UartInit
{
	();sendString
	("welcome:\r\n");while
	(1)judgeInformation
	{
		();}
	}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/707153.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-24
下一篇 2022-04-24

发表评论

登录后才能评论

评论列表(0条)

保存