How to use Bluetooth HC-06
The Bluetooth module HC-06 is cheap and easy to use. Through the module you can connect with your arduino. In this tutorial will show you how to control the diode (pin 13) in arduino by phone. Arduino is powered by 5 volts, the logic works in 3.3volt. If you do not have a logic level converter, you can use the voltage divider. In Arduino is only one serialport , so you must use a virtual serialport.
Fast Tutorial Video:
Schema:

Code Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
include <SoftwareSerial.h> SoftwareSerial BT(9, 10); // creates a "virtual" serial port/UART // connect BT module TX to D9 // connect BT module RX to D10 // connect BT Vcc to 5V, // connect BT GND to GND void setup() { // set digital pin to control as an output pinMode(13, OUTPUT); // set the data rate for the SoftwareSerial port BT.begin(9600); // Send test message to other device BT.println("Hello from Arduino"); } void loop() { // if bluetooth is available if (BT.available()) { // read the value read in a variable value value=(BT.read()); // if the value is zero, set the LOW state on pin 13 if (value=='0') { digitalWrite(13, LOW); BT.println("LED off"); } // if the value is zero, set the HIGH state on pin 13 if (value=='1') { digitalWrite(13, HIGH); BT.println("LED on"); } } } |