Interface and Application Programming


For this assigment, we have to:

- (DONE) Write an application that interfaces with an input and/or output device that you made, comparing as many tool options as possible.

All the files created for this assigment can be found on the link bellow:


---> DOWNLOAD FILES<---



Have you:

- Described your process using words/images/screenshots?
--> yes
- Explained the the GUI that you made and how you did it?
--> yes
- Outlined problems and how you fixed them?
--> yes
- Included original code?
--> yes




Pairing PC with HTC06 module

For this assigment, I comunicated the input board of my 13th assigment with my personal computer by using MATBLAB, MATLAB GUIDE and a bluetooth module HC06.

1.Firstly, any bluetooth module can only be detected by the PC if it is working as a server. So I took the bluetooth module configured as SLAVE(server) of my 15th assigment, connected it to my input device board and powered the board.

2. Then, I turned on the bluetooth on my pc(running windows 10) by going to configuration->bluetooth device manager->activate

3. Then, the SLAVE module appeared as visible and I clicked on pairing.

4. Once I clicked a window appeared requesting me a pin number which the password that was previously set on the module(this is explained on the 15th assigment)

5. I waited a couple of secods until the pc and the bluetooth module were paired. This means that they are sinchronized and ready for establishing a communication.




Making a GUI

For communicating the pc with the input device board, I created a program on Matlab with a user interface. The interface consists on two buttons and two axes, one button for starting the bluetooth connection and transmition of data, one button for stoping the transmition of data, and a couple of axes where the data is plotted. In general, for doing the user interface, I did the next steps:

1. First, I wrote "guide" on the command line, hitted enter and clicked on Blank GUI on the window that appeared.

2. Then, on the blank window (a figure) that appears I dragged two buttons and a couple of axes.

3. I double clicked the buttons and on the window that appears(properties), I changed the string shown on each button to "transmite" and "Stop" and then saved the figure

4 I right clicked on a blank part of the window(figure) and then clicked on editor. On the code that appeared, I went to the function interface1_OpeningFcn and defined a variable that acts as a stop condition. What this does is to create that variable as soon as the interface loads.



5. Then, I rigth clicked on the transmite button and then on viewcallbak for going to the section of code that runs when the button is pushed. On that section, I wrote a code for connecting the pc with the bluetooth module, a code for recieving and process all the information sent by the bluetooth module (this code is executed while stop condition is equal to 1) and a code for plotting on the couple of axes the information recieved (explained on next section).


6. Then, I right clicked on the stop button and on viewcallback and then setted the stop condition variable to 0. So, when this button is hitted, the variable changes to 0 and the transmition code stops to work (explained on next section).




Programming connection, communication and plotting


The code works as follows:

1. First, it looks for bluetooth module on the paired devices with the pc.

2. It creates a bluetooth object, based on the bluetooth channel obtained on the previous step and defines the input buffer size.

3. It closes the bluetooth port if is oppened and then opens the port of communication.

4. It starts to hear for incomming data. If the data received starts with the words "Distance" it saves that data to one array; If the data starts with the word Hall, it save the data to another array.

5. If the number of samples obtained is pair plot the datta of the Distance array on one axes and the data of the Hall array on the second axes.



Testing the program and interface

For oppening the interface I write the name of the program on the console and hit on enter


Then, I power the board, turn on the bluetooth on my pc and click on the button Transmit. If I want to stop the transmition of data, I click on stop.