WEEK THIRTEEN

INTERFACE PROGRAMMING

Since last week I programmed a board of NTC, and now I am using Processing 3 to build an interface and display the temperature with a figure.

Processing is based on Java. However, its language somewhat look like Arduino. You can also download a library of arduino so that you can use more orders only included in Arduino IDE on the Processing.

TESTING THE SERIAL PORT

We have alrealdy received the data from the board on Arduino Serial, but how to import the Serial Signals to Processing?

Well, we can import "processing.serial" and use a virtual serial port like the one in arduino to solve this problem. Here are testing code for virtual serial in Processing.

Download code: serialtest.pde


However, I found that processing is reporting an error. I found that I made a mistake on the code of my board: when I use "println" to output the data, the serial port will receive a string, which means if I "int a". processing cannot convert the string variable to an integral. So I changed "println" to "mySerial.write" and solved the problem.



Download code: NTC.ino


BUILD THE INTERFACE

For the interface, I expanded the code of serialtest and made a dynamic linechart to present the temporary temperature.

Download code: NTC.pde


FIXING THE PROBLEMS AND TEST THE INTERFACE

At the first time, when the window showed up, I found one error: cannot find the port. So I went to the line to test which port (0,1,2) is the usbserial port I was using. The answer is 1.

Another problem was that the data is beyond the upper boundary of the interface. So I adjusted the size of the window and the proportion of data to the height of points.




The previous code and interface





The modified code and interface





<< BACK TO INDEX


Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.