新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > #51單片機(jī)#藍(lán)牙模塊(ATKSPPHC06從機(jī)串口)的使用方法

#51單片機(jī)#藍(lán)牙模塊(ATKSPPHC06從機(jī)串口)的使用方法

作者: 時(shí)間:2016-11-19 來(lái)源:網(wǎng)絡(luò) 收藏


#include #include // 函數(shù)原形定義#define uchar unsigned char#define uint unsigned int void main (void);					// 主函數(shù)void LED_OUT(uchar X);				// LED單字節(jié)串行移位函數(shù)void LED_print (uchar p, uchar x) ;unsigned char code LED_0F[];		// LED字模表sbit DIO    = P1^0;				//串行數(shù)據(jù)輸入sbit RCLK   = P1^1;				//時(shí)鐘脈沖信號(hào)——上升沿有效sbit SCLK   = P1^2;				//打入信號(hào)————上升沿有效uchar Buffer[4] = {0};          //從串口接收的數(shù)據(jù)// 全局變量uchar LED[8];	//用于LED的8位顯示緩存void Delay_1ms(uint i)//1ms延時(shí){uchar x,j;for(j=0;jinterrupt 4{EA = 0;if (RI == 1) //當(dāng)硬件接收到一個(gè)數(shù)據(jù)時(shí),RI會(huì)置位{Buffer[0] = SBUF ; //這里減去48是因?yàn)閺碾娔X中發(fā)送過(guò)來(lái)的數(shù)據(jù)是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};


評(píng)論


技術(shù)專區(qū)

關(guān)閉