14. Interface and application programming

On this page we expose the different tools we have used for this interface and application programming week. Most of our projects were conducted using a HC-06 Bluetooth module.


Arduino Bluetooth Controller

The Arduino Bluetooth Controller application offers 4 modes :

  • Controller mode.
  • Switch mode.
  • Dimmer mode.
  • Terminal mode.

We have mainly experimented with the Terminal mode that allows to send any character through the phone keypad and the Controller mode that allows to map a dedicated character to 10 possible predefined buttons arranged as a gamepad (directional arrows, start / select buttons, etc).

Arduino BT Controller
Arduino BT Controller - Controller mode

Quentin

After a few basic communication tests with an Arduino and the HC-06 module, I associated characters to different actions and managed to interact with my puzzle box final project through the Android Bluetooth Controller application in Terminal mode as demonstrated in the video hereunder :

Note: I apolagize for the LCD text that can unfortunately not be read due to light conditions issues.

A few examples of the controls implemented :

  • Sending ‘r’ from the application to the microcontroller over Bluetooth, turns on the RGB LED in red.
  • Sending ‘g’ from the application to the microcontroller over Bluetooth, turns on the RGB LED in green.
  • Sending ‘b’ from the application to the microcontroller over Bluetooth, turns on the RGB LED in blue.
  • Sending ‘o’ from the application to the microcontroller over Bluetooth, turns off the RGB LED.
  • Sending ‘s’ from the application to the microcontroller over Bluetooth, starts/resumes the countdown.
  • Sending ‘p’ from the application to the microcontroller over Bluetooth, pauses the countdown.
  • A feedback has been implemented so that a message is displayed on the Arduino Bluetooth Controller application each time a character is received by the microcontroller.

Arduino BT Controller - terminal mode
Arduino Bluetooth Controller - Terminal mode

Tha Arduino Bluetooth Controller application allows to easily test bluetooth communication, nevertheless it does not offer a lot of interface customization possibilities. MIT app Inventor is much more appropriate for doing so.


MIT app inventor

The MIT App Inventor is an intuitive, visual programming environment that allows to rapidly build applications for smartphones and tablets, using a blocks-based approach.

List of helpful tutorials :

Quentin

Here below is presented a screenshot of the first version of the application I created and a video demonstrating how the application allows user to interact with the puzzle box electronics.

MIT App Inventor - Puzzle Box
Puzzle box application - MIT App Inventor

Note : In the video, one can notice that the text of “Puzzle 1” and “Puzzle 2” buttons disappears when interaction occurs with the application. I did not understand this issue given that the 4 puzzle buttons were configured exactly in the same way. Nevertheless I later managed to fix this issue by rearranging all the puzzles buttons on the same line.

1 - First thing to do was to create the design of my application, in the Designer view. This step was pretty simple, and consisted in dragging/dropping elements of diffrent types (buttons, labels, checkboxes, etc) from the “Palette” window to the “Viewer” window, and then adjusting the object properties to deal with font, size, alignment, etc.

MIT App Inventor - Designer
MIT App Inventor - Designer view

2 - Then functionalities must be allocated to the elements that makes up the application, and this was taken care of in the Blocks view. Once again, this step consisted in dragging/dropping blocks that could be assembled as pieces of a jigsaw puzzle.

MIT App Inventor - Blocks
MIT App Inventor - Blocks view

In the screenshot above, the upper blocks deal with the Bluetooth functionality, and the others blocks deal with the buttons that allow to interact with my puzzle box electronics.

Note : As can be seen in the screenshot below, there exist several ways to allocate a character to a button :

MIT App Inventor - Blocks
MIT App Inventor - Blocks view

3 - For testing the application in real time as I was developing it, I could establish a link between my computer and the MIT AI2 Companion application on my phone using either a QR-code or a 6 digits password. Note : This required both my computer and phone to be connected to the same wifi network.

MIT App Inventor - Communication
MIT App Inventor - Communication with “MIT AI2 Companion” phone application

4 - Once I was happy with the application I developed and tested, I could generate the final application through the “Build” menu. Two options were available, either generating the application as an “.apk” file and then installing in the phone, or generating a QR code that would deal with the application installation on the phone.

MIT App Inventor - Build
MIT App Inventor - Build application

MIT App Inventor - QR code
MIT App Inventor - QR code to install final application

After the application is installed on the phone, it can be used independently of the computer MIT App Inventor, and does not require any internet connection.