In this project we are going to make a project with VL53L0X is a Time of Flight distance sensor to measure the distance of the obstacle and display the distance of the obstacle on the Nextion Display. If the distance will be too short the font of the displayed distance will change from Black to Red.
You will learn how to send commands for changing font color from Arduino to Nextion Display using Visuino program.
Check my other Nextion projects to get more ideas!
Watch the Video!
In the Toolbar click on the "Compile" buttonIn the Menu Select "File" > "TFT File Output"Set the Output folder & click on the "Output" buttonSave the File to the SD cardInsert the SD card to your Nextion DisplayPower the Arduino and you will notice that the Nextion Display will start to Update it selfOn the Finish disconnect the power and remove the SD card from the Nextion display
Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2
Note: to get the value for the color select the Text Element in Nextion editor and in the properties window search for "pco" and you will see the value number for the selected color
Add "Time Of Flight Laser Ranger VL53L0X" componentAdd "Analog Multi Source" componentAdd "Analog To Text" component, and in the properties window set "Precision" to 0Add "Compare Analog Value" and in the properties window set "Compare Type" to ctBigger and "Value" to 50Add another "Compare Analog Value" and in the properties window set "Compare Type" to ctSmaller and "Value" to 50
Before Uploading Disconnect RX pin on Arduino and connect it back after the Upload.
In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.
If you power the Arduino module and put the obstacle in front of the VL53L0X sensor Nextion display will show the distance of the obstacle in mm, if the distance is lower then 50mm the font color will change to red.
This approach of using commands can also be used for changing other properties in the Nextion display.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu