Controlling Devices Wirelessy From Your Phone Using Arduino Bluetooth Module

by FABLABJubail in Circuits > Arduino

1101 Views, 18 Favorites, 0 Comments

Controlling Devices Wirelessy From Your Phone Using Arduino Bluetooth Module

image002.png

In this project we will explain how to connect and control an Arduino and the devices connected to it, from your iPhone using the Bluetooth module (KEYES HM-10 Bluetooth 4.0 Serial Port Module)

you can use the same concept to simply control LED or you can go all the way to control a Quadcopter or a Robot

you'll just need to write some code for the Arduino to do a certain command for each different bit of data (Letters or numbers) which is received from your phone

Download

to send and recieve data from your phone you need an app that simplify the job for you ,An app that send data through Bluetooth , I used this app "JBWave_v03" By Casey Brittain
or Amarino_2 for Android , you can download it from his website ( http://www.amarino-toolkit.net ) or directly from here , there is tons of other applications in the Android store when you search for 'Arduino bluetooth'

Hardware

  • KEYES HM-10 Bluetooth 4.0 Serial Port Module
  • Arduinouno Microcontroller
  • Iphone
  • The app ( JBWave_v03) By Casey Brittain
  • Jumper caple

How Does It Work

in this step we need to connect the Bluetooth module with the Arduino , for this module the password for pairing was 12334 , so from your phone just activate Bluetooth and search for device as usual , you'll find the Bluetooth module if it was active and connected to power source ( as in the attached picture in the next step) , if the phone didn't detect the Bluetooth module then try directly to search again from the app that you downloaded (JBWave in my case) which will pair the iPhone Bluetooth to the module,

then whatever you write or click in the app will be sent directly to the Bluetooth module connected to Arduino serial port

we are sending the command from iPhone to the Arduino to do the action, in this example the action is to turn two LEDs On and Off

the commands are basically different letters that will trigger different commands within the Arduino code

and here are the cases if you send a letter from the iPhone to the Arduino

  • send the letter A to turn the LED in port 7 ON
  • send the letter B to turn the LED in port 7 OFF
  • send the letter C to turn the LED in port 8ON
  • send the letter D to turn the LED in port 8OFF
  • send the letter E to turn the LED in port 7 and 8 together ON
  • send the letter F to turn the LED in port 7and 8 together OFF

Bluetooth Module is connected to Arduino Serial port, so the code is simply a loop that keep reading the incoming data coming through the serial port , if it detect one of cases above , it will change state of one of the GPIO Pins

Connection

image001.jpg
  1. Ultrasonic
    1. Vcc to 5V in the arduino
    2. TX to RX port 0 in the arduino
    3. RX to TX port 1 in the arduino
    4. Gnd to Gnd in the arduino
  2. LEDs
    1. LED 1 to port 7 in the Arduino
    2. LED2 to port 8 in the Arduino

Code

Just copy the code to Arduino IDE and upolad it to your Arduino

void setup()

{

Serial.begin (9600);

pinMode(8, OUTPUT);

pinMode(7, OUTPUT);

}

void loop()

{

charval;

val = Serial.read();

if ((val>='a'&&val<='z') || (val>='A'&&val<='Z'))

{

Serial.println(val);

}

if ( val == 'a')

{

digitalWrite(7, HIGH);

delay(1000);

}

if ( val == 'b')

{

digitalWrite(7, LOW);

delay(1000);

}

if ( val == 'c')

{

digitalWrite(8, HIGH);

delay(1000);

}

if ( val == 'd')

{

digitalWrite(8, LOW);

delay(1000);

}

if ( val == 'e')

{

digitalWrite(8, HIGH);

digitalWrite(7, HIGH);

delay(1000);

}

if ( val == 'f')

{

digitalWrite(8, LOW);

digitalWrite(7, LOW);

delay(1000);

}

}

Conclusion

Controlling Arduino from your Phone using Bluetooth

so what did we learn today ? not that much! but at least hopefully you got an idea that using Bluetooth with Arduino is really simple , and it add lots of potential to your future projects so keep it in mind , you can check the video to see what the code does