Introduction: Arduino Bluetooth Control Basic Tutorial

Picture of Arduino Bluetooth Control  Basic Tutorial

In this tutorial I'll show you, How to control Arduino with your smart phone using, My app developed with app inventor 2.

Step 1: Things You Need

Picture of Things You Need

Hardware

    • Arduino
    • Bluetooth Module HC 05/06
    • LED
    • 220Ω Resistor
    • 2.2KΩ Resistor
    • 4.7Ω Resistor
    • Android device

    Software

    • Arduino IDE
    • App Inventor 2 (for create your app).

    Step 2: Watch the Video Tutorial

    Step 3: Schematics

    Picture of Schematics

    The circuit is so simple:

    Arduino Pins: Breadboard: Resistor: Bluetooth Module:

    • RX (Pin 0)--------------------------2.2KΩ--------------TX
    • TX (Pin 1)------------------------------------------------RX
    • 5v-----------------------------------------------------------5v
    • Gnd--------------------------------------------------------Gnd
    • Pin2,Gnd-------Led----------------220Ω
    • RX------------------------------------4.7Ω---------------Gnd


    Notes and Tips: You need to remove the RX and TX cables when you’re uploading the sketch to your Arduino.

    If the HC-05 Bluetooth Module asks for a password, It’s’1234′.

    Sometimes people connect the TX from the bluetooth module to the TX of the Arduino… that’s wrong and it won’t work. Make sure you connect it properly, the TX into RX and the RX into the TX.

    Step 4: Arduino Sketch

    int ledblue=2;

    int tx=1;

    int rx=0;

    char inSerial[15];

    void setup(){ Serial.begin(9600);

    pinMode(ledblue, OUTPUT);

    pinMode(tx, OUTPUT);

    pinMode(rx, INPUT);

    allpinslow();

    }

    void loop()

    { int i=0;

    int m=0;

    delay(500);

    if (Serial.available() > 0) { while (Serial.available() > 0) { inSerial[i]=Serial.read();

    i++; }

    inSerial[i]='\0';

    Check_Protocol(inSerial); }}

    void allpinslow() { digitalWrite(ledblue, HIGH);

    digitalWrite(ledblue, LOW); } void Check_Protocol(char inStr[]){ int i=0;

    int m=0;

    Serial.println(inStr);

    if(!strcmp(inStr,"2off")){ //Led Off allpinslow();

    digitalWrite(ledblue, LOW); Serial.println("Blue Off");

    for(m=0;m<11;m++){ inStr[m]=0;} i=0;} if(!strcmp(inStr,"2on")){ //Led on allpinslow();

    digitalWrite(ledblue, HIGH);

    Serial.println("Blue on"); for(m=0;m<11;m++){ inStr[m]=0;} i=0;} else{ for(m=0;m<11;m++){ inStr[m]=0; } i=0;

    }}

    Step 5: Android Application

    Picture of  Android Application

    App Inventor 2 project file:Designer and Blocks code.

    Comments

    liquidhandwash (author)2016-08-05

    Hi I couldn't get this to work, the LED will turn on and off if I use arudino serial monitor, and the phones blue tooth finds and connects to the module, there just seems to be no communication between the blue tooth module an the arduino. Ive tried 2 different HC6 modules and with and without the voltage divider. Any ideas?

    brunoip (author)2016-06-05

    can you upload an .apk for testing?

    LucianT6 (author)2016-05-15

    The 4,7k resistor is not connected to anything

    JoburgJim (author)LucianT62016-05-28

    The 4k7 and the 2k2 resistors are a voltage divider to drop the 5V output from the Uno's Tx pin to a lower voltage for the Bluetooth module which is not 5V tolerant. (5x 4.7/(4.7+2.2) = 3.4V)

    BlueMatter (author)LucianT62016-05-16

    It is connected to gnd and tx of the HC06 board.

    blic19933 (author)2016-05-12

    I like the idea of a basic tutorial to teach others. I would of liked to have seen cleaner arduino code for a tutorial. You have several lines of code that are not needed or do nothing. Pins 0 and 1 don't need pinMode. Serial.begin takes care of that. Your 2 Serial.println send data back over BT but your app is not programmed to receive it. Again I like the idea. Thanks

    wold630 (author)2016-05-12

    Thanks for sharing a beginner tutorial!

    About This Instructable

    7,874views

    169favorites

    License:

    More by BlueMatter:Connect and use Joystick with ArduinoArduino Tutorial - Laser security systemArduino Tutorial - Easy secret knock detector
    Add instructable to: