Interfacing Bluetooth with 8051
-
Upload
pantech-prolabs-india-pvt-ltd -
Category
Documents
-
view
1.324 -
download
10
description
Transcript of Interfacing Bluetooth with 8051
Interfacing Bluetooth with 8051 Microcontrollerswww.pantechsolutions.net
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
• Bluetooth is a proprietary open wireless protocol for exchanging data over short distances (using short length radio waves) from fixed and mobile devices, creating personal area networks (PANs). It was originally conceived as a wireless alternative to RS-232 data cables.
• BlueTooth is a promising standard for short range wireless communication. BlueTooth uses the same frequency as WaveLan but with much less effect but anyhow some claim that a WaveLan can not co-exist with a fully equiped BlueTooth environment.
• Bluetooth is a wireless technology for transmission of voice and data over a short distance.
• RXD and TXD pin of bluetooth Evaluation kit connected with the controller through serial port
WHAT IS BLUETOOTH?
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Bluetooth interface board
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Bluetooth interface
8051
HE
LL
O X
bee
!
2.4GHz RF Communicati
on
HELLO blue2th
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
Bluetooth interface with 8051
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
connection details1) Connect first bluetooth module to the PC 2) Connect the second blue tooth module to 8051 using serial port cable execute the program the massage
is being transferredWrite a program to transfer the message “YES” serially at 9600 baud, 8bit data, 1 stop bit interfacing with
BLUETOOTH module. Do this continuously. Solution:
MOV TMOD,#20H ;timer 1, mode 2MOV TH1,#-3 ;9600 baudMOV SCON,#50H ;8-bit, 1 stop bit, REN enabledSETB TR1 ;start timer 1
AGN: MOV A,#"Y" ;transfer "Y"ACALL XMITMOV A,#"E" ;transfer "E"
RETACALL XMIT
MOV A,#"S" ;transfer "S"ACALL XMITSJMP AGN ;keep doing it
;serial data transfer subroutineXMIT: MOV SBUF,A ;load SBUFHERE: JNB TI,HERE ;wait for last bit to transfer
CLR TI ;get ready for next byte
BLUETOOTH INTERFACE ASSEMBLY CODE
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
// program to accept commands from PC via Bluetooth// USB-Bluetooth adapter is connected to PC// here Bluetooth module is interfaced with 89C51#include <REG51F.H>void delay(unsigned long); void send command(unsigned char array[]); void transmit(unsigned char);unsigned code char setcon[]="set connectable on";void main()
{ send_command(setcon);
delay(50000);while(1){
TMOD=0X20; TH1=0XFD; SCON=0X50;
TR1=1; SBUF=dat;
while(TI==0) { } }
void delay(unsigned long count){
unsigned long i;for(i=0;i<count;i++);
}
BLUETOOTH INTERFACE C CODE
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
void send_command(unsigned char array[]) {
unsigned char i; TMOD=0X20; TH1=0XFD; // baud 9600Kbps @ 11.0592 Mhz
SCON=0X50; TR1=1;
for(i=0;array[i]!='\0';i++) { SBUF=array[i]; while(TI==0) { TI=0;
}
SBUF=0x0D; while(TI==0) {} TI=0; SBUF='\n'; while(TI==0) {} TI=0;
}
C CODE CONTD
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt Ltd.
For More Tutorials
www.pantechsolutions.nethttp://www.slideshare.net/pantechsolutionshttp://www.scribd.com/pantechsolutionshttp://www.youtube.com/pantechsolutions