Skip to content

16. Interface and application programming

For this week’s assignment I have used platform to create mobile application.

Also I have used HC-06 Bluetooth module to connect my board and smatphone. I have used this tutorial to create my application.

The beauty of the Bluetooth mode is that it communicated with the microcontroller via RX and TX pins. Therefore, the logic of communication is very easy to understand. The communication happens in the same way as the communication via the serial monitor.

The application sends the message. The program of the board receives the message and do something accordingly.

For example, the connection process looks like these steps:

  • We chose the device in the application
  • The application sends the message to the board via Bluetooth
  • The Bluetooth send the message via TX pin to RX pin of the board
  • The microcontroller receives the message, and the program recognize it
  • The program sends the message specific message via TX pin to the Bluetooth device
  • The Bluetooth device sends the message to an application
  • In case the application receives the right message the connection process is established

The board view with connected HC-06 module

The desing of application in MIT app inventor

The logic of the application

Download and installation

App view on smartphone

Selecting Bluetooth device


An application is down when I try to connect to bluetooth device


However, I finally found the problem. The problem was that the function sendCheckBoxState of the app have not properly communicated with the application on the board.

The function is part of the connection process.

The application starts communication with the program on the board and starts receiving the messages.

First, the application sends the message off, the application program receives it activates Serial.write("led is off"). The application receives it as the number of bites, which is ten as the message has ten symbols. The application receives 10 bytes and shows the text. The function is over.

The problem was that I put the wrong number in the first version. I put 14 bytes. Therefore, the function could not be finished, and the application went down.

After I made these corrections, the application started to communicate with the board properly.

It was working for both on and off commands.



int light = 13;

void setup() {

  pinMode(light, OUTPUT);
  digitalWrite(light, LOW);

void loop() {
  String t; 
  while(Serial.available()) { 
    t += (char); 

  if(t.length()) { 
    if(t == "on") { 
      digitalWrite(light, HIGH); 
      Serial.write("led is on"); 
    else if (t == "off") { 
      digitalWrite(light, LOW);  
      Serial.write("led is off");