Overview
Inventor of the MIT APP Arduino Bluetooth application. I have used Bluetooth mobile phone applications to monitor and control various types of sensors and electrical loads. I developed all my previous apps in Android Studio. A few months ago I uploaded articles on how to develop a custom Android app to control electrical loads and how to develop a custom Android mobile phone app to monitor sensors connected to Arduino. These two items have become very popular and have helped many boys and girls to develop their own mobile phone applications to control and monitor Arduino related electronics. So if you like Android Studio, you should read these articles. If you think that programming is difficult for you and you are comfortable working with just drag and drop, then this article is for you. Because the application for mobile phones that we are going to make today does not require programming. Marvellous!!!
In this article, I will use MIT APP Inventor to develop a Bluetooth enabled application that can be used with Arduino boards using a Bluetooth module such as the HC05 or HC06, or any other Bluetooth module. But in this article, I will use the HC05 Bluetooth module, which I have used in many projects. You can also check out my other Android projects.
Digital Pins connection:
S.No | Digitalpin_connection |
1. | Digital pin 11 ( output) |
2. | Digital pin 12 ( output) |
3. | Digital pin 13 ( output) |
4. | Digital pin 0 ( Rx) |
5. | Digital pin 1 ( Tx) |
Block diagram:
About Bluetooth module HC-05:
HC-05 is a Bluetooth module which is designed for wireless communication. It uses serial communication to communicate with devices. HC-05 has a red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to the HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds.
It is used for many applications like wireless headsets, game controllers, wireless mice, wireless keyboards and many more consumer applications. To communicate smartphone with the HC-05 Bluetooth module, the smartphone requires a Bluetooth terminal application for transmitting and receiving data.
About serial communication:
If the data is sent in series i.e. one after the other then the communication protocol is known as Serial Communication Protocol. In serial communication, data is sent in the form of bits i.e. binary pulses and it is well known that binary one represents the logic HIGH and zero represents the logic LOW.
Serial communication is the most widely used approach to transfer information between data processing peripherals. The protocol is a secure and reliable form of communication having a set of rules addressed by the source host (sender) and destination host (receiver) similar to parallel communication. there are several examples of Serial Communication Protocols such as CAN, ETHERNET, I2C, RS232, SPI, USB, 1-Wire, SATA etc.
Step by step execution process:
Creating Mobile APP using MIT APP inventor:
Step 1: Open the MIT app inventor website and click on “create apps”.
https://appinventor.mit.edu/explore/get-started
Step 2:I would like to give the name to the app as Bluetooth and then hit on OK so you see it creates a project with the name Bluetooth. It takes a couple of minutes and then it will straightaway take you to the project itself.
Step 3: Choose the option to start a new project, the window is shown below figure.
Step 4: In the designer section, start building the app interface.
Step 5: First select the “list picker” in the palette window and drag and drop it in the mobile window and modify the interface by changing the properties in the window.
Step 6: Now select “layout” in the palette and drop them in the mobile window and modify them using properties.
Step 7: Next drag and drop the buttons in the mobile window and modify them by using the properties window, the app interface will look as shown below figure.
Step 8: In the blocks section, build the functional blocks of the app, the window is As shown in the below figure.
Step 9: Build and download the .apk file and install it on the mobile device.
Step 10: Now connect the Bluetooth module’s VCC to the +5v to the microcontroller and also the ground pins.
Step 11: Connect the Bluetooth’s Tx pin to the Rx of the microcontroller and Rx pin to the Tx pin of the microcontroller.
Step 12: Connect the digital pins 11,12 and 13 to the LEDs.
Step 13: Write the code in the Arduino for selecting the output pins “pinMode();” the command should be given.
Step 14: Give the commands HIGH and LOW for turning the LEDs on/off.
Step 15: Upload the final code and open the app on mobile.
Step 16: Connect to the Bluetooth and verify the output by turning on and off the LEDs through the app, the app interface will look as shown below figure after it is connected.
MIT App Inventor HC05 with Arduino Programming:
char Incoming_value = 0;
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read();
Serial.print(Incoming_value);
Serial.print("\n");
if(Incoming_value == '1')
{
digitalWrite(12,LOW);
}
else if(Incoming_value == '0')
{
digitalWrite(12, HIGH);
}
if(Incoming_value == '2')
{
digitalWrite(11,LOW);
}
else if(Incoming_value == '3')
{
digitalWrite(11, HIGH);
}
}
}