In this tutoria,l I'll show you how to get started with Bluetooth Low Energy and how you can control your projects with it. This will be basic and I'll try to keep it simple for beginners. I'll be using AT-09 BLE v4.0 which is a HM-10 compatible Bluetooth module. BLE stands for Bluetooth Low Energy, It is based on Bluetooth 4.0 technology. So this module won't work with older phones. Click here to learn more about BLE. If you don't have HM-10/AT-09 module you can use regular old HC-05. So lets get started...
Here I've listed all the components along with best buy links. You can find the components at UTSouce.net
- Arduino (I've used UNO, You can use any other board like Nano/Pro Mini etc.)
- Bluetooth Module (I've used AT-09. You can use HM-10/HC-05)
- Breadboard. (I recommend you get this kit.)
- 1k resistors. (Can be found in any local electronics store.)
- Smart Phone ( with Bluetooth 4.0 or above.)
- Serial Bluetooth Apk.
NOTE :- Most of the GUI control apps do not work with BLE modules.
- Connect the Bluetooth module on bread board.
- We need to divide the voltage sent to the receive pin because Arduino's pins output is 5v and our bluetooth module's receive pin needs 3.3v so we make a voltage divider using a 1k and a 2k ohm resistors.(as I didn't have a 2k resistor I've use two 1k resistors in series)
- Now make the following connections :-
VCC -> 5v
GND -> GND
TX -> RX
RX -> TX
NOTE :- Connect the resistors to bluetooth module as shown in the picture. Then connect one end of resistor(2k) to GND and other resistor (1k) to TX pin of arduino.
- Now connect two LEDs on breadboard in series with 1k resistors. and connect the LEDs to arduino's pin no. 8 and 9.
- After the connection is done, We move on to the next part i.e coding...
- First open the Arduino IDE and write the following code. (I recommend you write it as it will be easy to understand than just coping it.)
int led1 = 8;
int led2 = 9;
int flag1 = 0;
int flag2 = 0;
data == Serial.read();
if(data == '1')
if(flag1 == 0)
Serial.println("LED 1 is on");
flag1 = 1;
else if(flag1 == 1)
Serial.println("LED 1 is off");
flag1 = 0;
if (data == '2')
if(flag2 == 0)
Serial.println("LED 2 is on");
flag2 = 1;
else if(flag2 == 1)
Serial.println("LED 2 is off");
flag2 = 0;
- Once you have written the code compile it and before you upload you first have to do one thing. Remove the connection to TX & RX pins of arduino. When you have removed the pins upload the code to arduino and you are ready to go.
- But before you reconnect the pins. Open the Serial monitor of arduino IDE and enter 1 and you should see the LED turn on similarly entering 2 will turn on second LED and entering the same numbers will turn the LEDs off.
After this is done we move on to connect our setup with Smartphone.
- To connect the phone to Bluetooth first you need a Bluetooth Serial App. I've used Bluetooth Serial Terminal.
- After connection is established long press the 'M1' to assign it a value. Assign 'M1' = 1 and 'M2' = 2.
- Now power up the arduino and clicking M1 will turn on a LED and clicking again will turn it off, Same with M2.
That's all now you know how to control LEDs with Arduino through Bluetooth. Now you can tinker around to control your own projects.
If you have any questions or face any difficulty feel free to ask.
In next tutorial, I will share how you can make Bluetooth controlled car/bot. Follow me to get notified.