Click here to load reader
Upload
sumit-chakraborty
View
4.735
Download
0
Embed Size (px)
DESCRIPTION
This presentation describes how to send and receive data between two Arduino boards using RN-42 Bluetooth.
Citation preview
INTERFACING TWO ARDUINO BOARDS USING RN-42
BLUETOOTH
Presented By: Sumit
chakraborty
Basic Command SetsSTEP- 1:
Cont..
STEP- 2: Connect Your device With bluetooth and pc.
STEP -3 : Change to command mode($$$)
STEP -4: Press D to see your Bluetooth configuration.
Cont..
Some Basic Modes Of Operation
1. Slave Mode(SM,0) – This is default mode.
2. Master Mode(SM,1) – This mode is useful when the device wants to initiate connection
Command Mode VS Data Mode
Upon power up the device will be in data mode. To enter command mode, send the characters “$$$” through the serial port or from the remote Bluetooth connection.
To exit command mode, send “---<cr>”
HOW TO CHANGE THE Baudrate
Default Baudrate is 115200 To change to 9600 – SU,96
Range of Baudrate the module supports:
{1200, 2400, 4800, 9600, 19.2, 28.8, 38.4, 57.6, 115K, 230K, 460K,
921K },
Program of Master Bluetooth module
//Master// Before going forward first Download TextFinder.h#include <TextFinder.h>
String Remote ="00066649533C"; // Address of slave devicevoid setup(){ Serial.begin(9600); //baudrate Serial.print("$$$"); // command mode delay(100); Serial.println("c,"+ Remote +"\r"); // connect to the device delay(100); Serial.println("SM,1"); // master delay(100); Serial.println("---,"+ Remote +"\r"); // exit from command mode and enter data mode delay(100); }
Cont..void loop(){ Serial.println("L"); // Send ‘L’ in data mode delay(100); Serial.println("H"); // Send ‘H’ in data mode delay(100);}
Program for Slave Blutooth module
//Slave#include <TextFinder.h>
String Remote ="0006664953B0"; // Address of master bluetoothvoid setup(){ Serial.begin(9600); // baudrate Serial.print("$$$"); // command mode delay(100); Serial.println("c,"+ Remote +"\r"); // connecting to the slave delay(100); Serial.println("SM,0"); // slave mode delay(100); Serial.println("---,"+ Remote +"\r"); // exit from command mode delay(100); }
Cont..void loop(){
if(Serial.available() > 0) // Check if data is available { char ch = Serial.read(); // read the incoming data if(ch == 'L') { digitalWrite(13,HIGH); delay(100); } else if(ch == 'H') { digitalWrite(13,LOW); delay(100); } }}