Home > other >  Help PIC microcontroller and HC06 bluetooth module
Help PIC microcontroller and HC06 bluetooth module

Time:10-18

One is connect the RX and RX and TX and TX connection, the bluetooth module will enter the AT mode, I can't connect computer here bluetooth, because no TTL tieline, excuse me I can use a mobile phone bluetooth serial port software to set the AT? But the problem is the mobile phone with bluetooth connection directly, can only be matched, then has not AT mode...
Second, I now choice is to skip the AT mode, the RX and TX, TX and RX, into normal work mode, but after the success of the match, light is normally on the bluetooth module, but send any messages on the mobile phone bluetooth assistant App, single-chip computer all have no reaction, nor any return, my LCD and six leds as the output, all have no reaction,
Have bosses can answer it for me?

CodePudding user response:

Uchar num, rcnum, comd [2];
Uint I;

Void delay (uint t);
Void eusart_init ();

Void write_commod (uchar commod);
Void write_data (uchar data);
Void init_lcd ();
Void LCD_disp_char uchar x, uchar y, uchar (dat);

Void main ()
{num=0;
i=0;

TRISC=0 x0;
PORTC=0;

Init_lcd ();
Eusart_init ();

LCD_disp_char (0, 1, 'R');
delay(1);
LCD_disp_char (1, 1 'X');
delay(1);
LCD_disp_char (2, 1, ', ');
delay(1);
LCD_disp_char (0, 2, 'T');
delay(1);
LCD_disp_char (1, 2, 'X');
delay(1);
LCD_disp_char (2, 2 ', ');
delay(1);

TXREG='A';
while(! TRMT);
TXREG='T'.
while(! TRMT);
LCD_disp_char (3, 2, 'A');
LCD_disp_char (4, 2, 'T');

While (1)
{
If (I==2)
{
If (comd [1]=='K')
{
If (comd [0]=='1') led1=1;
If (comd [0]=='2') led2=1;
If (comd [0]=='3') led3=1;
If (comd [0]=='4') led4=1;
If (comd [0]=='5') led5=1;
If (comd [0]=='6') led6=1;
}
}

}

}

Void delay (uint t)
{
uint x,y;
For (x=t; X> 0; X -)
For (y=100; y> 0; y--);
}

Void eusart_init ()
{
TRISC7=1;
TRISC6=1;
SPBRG=25;
TXSTA=0 x24;
RCSTA=0 x90;
RCIE=1;
TXIE=0;
PEIE=1;
Govemment=1;

}

Void interrupt rx_int ()
{

If (RCIF==1)
{
If (I==2) I=0;
Rcnum=RCREG;
LCD_disp_char (num + 3, 1, rcnum);
Comd [I]=rcnum;
i++;
delay(500);
num++;

}

}
Some major code as shown in figure, there is something wrong with the code
  • Related