51单片机的蓝牙模块,是在蓝牙通讯的基础上,进行蓝牙51模块与外部蓝牙发射接收设备之间,相互收发数据。并且其引脚为VCC,GND,TXD,RXD,可以通过串口通信与外部上位机或单片机通信。
代码如下(注意蓝牙模块是5V供电)
#include<reg52.h>
void init();
void delay(unsigned int ms);
unsigned char input;
void display(unsigned char num_decimal);
unsigned char code character[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,
0xf8,0x80,0x90};
sbit SegSelection1=P2^0;
sbit SegSelection2=P2^1;
sbit SegSelection3=P2^2;
sbit SegSelection4=P2^3;
sbit p1=P1^0;
sbit p2=P1^1;
void main()
{
p1=1;
p2=0;
init();
while(1)
{
display(input);
}
}
void init(void)
{
EA = 1;
ES = 1;
PCON = 0x00;
SCON = 0x50; //串口工作在方式1,