#51单片机#蓝牙模块(ATKSPPHC06从机串口)的使用方法
时间:11-19
来源:互联网
点击:
#include #include// 函数原形定义#define uchar unsigned char#define uint unsigned int void main (void); // 主函数void LED_OUT(uchar X); // LED单字节串行移位函数void LED_print (uchar p, uchar x) ;unsigned char code LED_0F[]; // LED字模表sbit DIO = P1^0; //串行数据输入sbit RCLK = P1^1; //时钟脉冲信号——上升沿有效sbit SCLK = P1^2; //打入信号————上升沿有效uchar Buffer[4] = {0}; //从串口接收的数据// 全局变量uchar LED[8]; //用于LED的8位显示缓存void Delay_1ms(uint i)//1ms延时{uchar x,j;for(j=0;jinterrupt 4{EA = 0;if (RI == 1) //当硬件接收到一个数据时,RI会置位{Buffer[0] = SBUF ; //这里减去48是因为从电脑中发送过来的数据是ASCII码。// Buffer[0] = SBUF-48 ;RI = 0; }EA = 1;}void LED_print (uchar p, uchar x) {unsigned char code *led_table; // 查表指针uchar i;unsigned long loop;led_table = LED_0F + x;i = *led_table;LED_OUT(i); LED_OUT(p); RCLK = 0;RCLK = 1;for(loop = 0; loop < 230; loop++);}void LED_OUT(uchar X){uchar i;for(i=8;i>=1;i--){if (X&0x80) DIO=1; else DIO=0;X<=1;SCLK = 0;SCLK = 1;}}unsigned char code LED_0F[] = {//0 1 2 3 4 5 6 7 8 9 A b C d E F -0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, 0xbf};
51单片机蓝牙模块ATKSPPHC0 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)