原标题:c51:串口通信,按键发送字符串
一、程序功能
1、实现0~f的16位键盘输入功能,将键值由P1口输出。
2、不同的键值串口发送不同的
二、代码
//函数功能
//1.实现0~f的16位键盘功能,将按键表示的数字由数码管显示
//2.定义不同的按键表示发送不同的字符串
#include"reg52.h"
#define uchar unsigned char
//16位键盘行翻转法对应键值。
//对应的键值为0~f
uchar code kcode[]={
0x77,0x7b,0x7d,0x7e,
0xb7,0xbb,0xbd,0xbe,
0xd7,0xdb,0xdd,0xde,
0xe7,0xeb,0xed,0xee};
//不同键值发送的字符串
uchar buf0[4]={0x11,0x12,0x13,0x00};
uchar buf1[5]={0x11,0x12,0x13,0x14,0x00};
uchar buf2[6]={0x11,0x12,0x13,0x14,0x15,0x00};
uchar buf3[7]={0x11,0x12,0x13,0x14,0x15,0x16,0x00};
uchar buf4[8]={0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x00};
//---串口初始化
//T1为波特率发生器,初始化T1
//f=11.0592,baud=9600
//串口中断执行数据发送