12

Click here to load reader

Interfacing two arduino boards using rn 42 bluetooth

Embed Size (px)

DESCRIPTION

This presentation describes how to send and receive data between two Arduino boards using RN-42 Bluetooth.

Citation preview

Page 1: Interfacing two arduino boards using rn 42 bluetooth

INTERFACING TWO ARDUINO BOARDS USING RN-42

BLUETOOTH

Presented By: Sumit

chakraborty

Page 2: Interfacing two arduino boards using rn 42 bluetooth
Page 3: Interfacing two arduino boards using rn 42 bluetooth

Basic Command SetsSTEP- 1:

Page 4: Interfacing two arduino boards using rn 42 bluetooth

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.

Page 5: Interfacing two arduino boards using rn 42 bluetooth

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

Page 6: Interfacing two arduino boards using rn 42 bluetooth

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>”

Page 7: Interfacing two arduino boards using rn 42 bluetooth

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 },

Page 8: Interfacing two arduino boards using rn 42 bluetooth

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); }

Page 9: Interfacing two arduino boards using rn 42 bluetooth

Cont..void loop(){ Serial.println("L"); // Send ‘L’ in data mode delay(100); Serial.println("H"); // Send ‘H’ in data mode delay(100);}

Page 10: Interfacing two arduino boards using rn 42 bluetooth

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); }

Page 11: Interfacing two arduino boards using rn 42 bluetooth

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); } }}

Page 12: Interfacing two arduino boards using rn 42 bluetooth