12. Interface and Application Programming#
Processing#
According to it’s homepage,
it is a flexible software sketchbook and a language for learning how to code within the context of the visual arts.
I created an interactive visual art within the screen, made an interface to control the movement of a servo motor, and an interface that visualizes the digital read of a thermistor.
An interactive visual art within the screen:
An interface to control the movement of a servo motor:
An interface that visualizes the digital read of a thermistor:
You can see more details in Yume’s individual assignment page.
With Processing, you can easily create a visual interface for an Arduino IDE coded hardware work.
Blynk (oguri)#
I tried Blynk to communicate with ESP32 via BLE. Although BLE is beta version at this moment ( as of 2020/07 ), this is a convenient and easy-to-use solution to control/monitor ESP32 from smart phone.
1) setting “Blynk BLE” on Arduino IDE#
Firstly, some libraries are needed.
How to install Blynk Library for Arduino IDE
I installed the following three libraries.
2) programming for ESP32, Blynk APP ( iPhone )#
(a) Controlling servo motors#
This short YouTube video is informative, to understand how to use Blynk BLE.
Blynk - Controle do ESP32 NodeMCU-32S via Bluetooth (BLE)
To create Blynk Account, and to get Auth Token, please refer this site.
In my iPhone, I added the Blynk “Widget” such as, BLE (beta), Slider and Joystick.
And set the parameters of the Widgets.
Joystick (SPLIT mode)
( In case of SPLIT mode, X-Y two parameters can be set separately. )
V1 for servo motor 1 min 0 - max 180
V2 for servo motor 2 min 0 - max 180
( “servo motor 1 and 2” are continuous rotation type, to control the Drive simulator shown in the video below. The values correspond to the speeds/directions of each servo motors. )
Slider
V3 for servo motor 3 min 10 - max 170
( “servo motor 3” is angle type, to control the slope of Drive simulator course shown in the video below. The value corresponds to the angle of servo lever. For the safe operation, the min/max value are set to be smaller than its allowable range. )
Programming for ESP32
After referring Blynk, ESP8266 wifi , I replaced “wifi” to “BLE” , increased the number of servo motors.
“ESP32_Blynk_BLE_DriveSim_servo.ino”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
If “MERGE-mode” is selected, in “Joystick” widget, X-Y two parameters have to be separated in the program.
1 2 3 |
|
For more information, please refer the site below.
This is the video, utilizing the above setting and program.
To download the above program, please refer “W11 - Output Devices, Hideo Oguri, Individual Assignment Page”.
(b) Monitoring thermistor#
In this case, I used “SuperChart” to display the time-based graph on iPhone.
assign “V0” in widget | |
---|---|
Regarding the detail of thermistor and downloading the program below, please refer “W09 - Input Devices, Hideo Oguri, Individual Assignment Page”.
“ESP32_Thermistor_BLYNK_BLE.ino”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
Key point is
assign “V0” in widget,
Blynk.virtualWrite(V0, temp); in program
This is the video, utilizing the above setting and program.
p5.js (oka)#
P5.js is a library of javascript and it enable us to use processing on the WEB easily.
There is a huge internet community and lots of users share their own programs.
This time, I tried to create color picker. I borrowed the color-picker program created by slow_izzm and customized it to meet my requirements.
My version
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
my version
for using my interface, I would use the value only 8bit RGB color code which control color by the value 0-255 of red, green, and blue. So I cut off extra information from the original to make it easier to understand at first sight.
There were lots of sample codes relating to visual and it was not so much difficult to program something by reffering to someone’s code.