ad space

Bluetooth Controlled LED using Arduino

 In this tutorial you will learn how to control a LED using your mobile phone via Bluetooth module HC-05 and Arduino. The Bluetooth HC-05 and LED are connected to Arduino. Using your Phone you can connect to the Arduino via Bluetooth and then using your Phone you can turn on and off the LED wireless. A Bluetooth application is created using MIT App Inventor to controls the LED. After creating the application it is downloaded into the Phone.  

HC-05 Bluetooth module has 6 pins which are the State, Rx, Tx, GND, +5V and En pins. The State pin is connected to a LED on the board to indicate state of the module. It may be connected to micrcontroller to read the state of the module. The LED indicates various state of the module. Repeated blinking of the led indicates that the module is waiting for connection. If the led blinks twice in a second then it is in connected state via bluetooth. If the LED blinks once in 2 second then it is in command mode. The Rx and Tx pins are used to connect to a microcontroller like Arduino. Ground and +5V are power supply for the module. The last pin which is the enable pin, En, is used to put the module into command mode. If it is left unconnected then it is in normal data mode. If it is pulled high then the module enters into the command mode where AT commands can be used to change the feature of the module.

Intefacing HC-05 Bluetooth Module with Arduino 

The Arduino USART pins, Tx(pin 1) and Rx(pin 0) pins are connected to the Rx and Tx pins of the HC-05 module as shown below. The Rx and Tx pins are both 3.3V pins but the logic level from the Arduino Tx pin is 5V. Hence the +5V signal from the Arduino Tx pin is reduced to 3.3V before it enters the Rx pin of the Bluetooth module using the 1.2KOhm and 2.2KOhm voltage divider resistors. The Tx pin of the module transmits 3.3V to the Arduino Rx pin which can detect the logic level as High so there is no voltage divider required in this connection. A LED is connected via 220Ohm resistor at pin 7 of the Arduino. The +5V and GND pin of the Bluetooth module is connected to the +5V and GND of the Arduino.

Bluetooth Controlled LED using Arduino

Creating Bluetooth Application in MIT App Inventor

MIT App Inventor is a free online application creating platform. What you need is just a gmail account. With the gmail account you can login and create application. After you have logged in, create a new project. As shown below, a table of project is shown and there is a tab to labelled Start new project. Click on that and give the new project a project name. In our case, there is already a project called LEDblink. 


After you create a new project, you will see the workspace with empty mobile phone layout as shown below. 


Using the User Interface elements on the left side and using the attributes of elements on the right side you can design an interface. The one we have created is as shown below. 


In the picture above, we have used a listpicker and two buttons elements. The first which shows Choose Bluetooth is a listpicker element and the two below that are two button elements which are labelled ON and OFF. The color, font size, text to be displayed etc are controlled by the element attributes panel on the right side.


The function or the application logic of each of the UI element programmed by switching to the Blocks view. 


In MIT App Inventor, the application is programmed using blocks. As shown in the above block diagram, the different elements like listpicker and button have different supporting blocks which performs specific functions. These blocks are dragged into the diagram workspace and glued together to make program statements. 

Once the program is completed, we can use the Build tab to compile and get the application on the net using the QR scan method as shown below.


Once you click on the App(provide QR code for .apk) the program will be compiled.


After the compilation stage is completed, you will be shown with Barcode link for the project.


Now you can take picture of this barcode and use later after installing MIT AI2 Companion application from google store to install the Android program in your mobile phone.

Other tutorials on Bluetooth module are as follows.

- HC-05 Bluetooth Module and ATmega328p USART Communication

- ATmega328p, Bluetooth and IR sensor Interfacing and coding


Post a Comment

Previous Post Next Post