In the previous instructable we saw how data is received from the Nextion. There was, however, only 1 page and 1 button sending 1 value. In this instructable we'll see how to deal with multiple pages, buttons and values that are sent "simultaneously".
As with the other 2 instructables, we'll do this without the libraries.
Step 1: Create Your Interface
Like in the previous instructable you can download the interface and I'll point out things to note:
- There are now 2 pages. Note the code in their "Preinitialize" events. This hides the text boxes.
- On page0 note that the "2 is a party" has 2 events. The touch press event sends the component's id ahead of the actual data (send component id is checked). The release event sends the data.
- The same goes for the buttons on page1.
- All the increment/decrement buttons have code to ensure that only positive numbers are entered.
Remember to compile the interface and copy the .tft file from the build folder to the SD card. Load the interface onto the Nextion via the SD card.
Step 2: Upload the Arduino Sketch
The previous two instructables shows the evolution of the code to get to here. This sketch can handle multiple values and multiple pages. You can easily add more functions to the sketch for your extra components and pages.
Once again I've tried adding enough comments to the sketch to make it easily understandable.
Step 3: Connect the Nextion to the Arduino
Connect the red and black wires to 5V and ground on the Arduino respectively. Connect the blue (TX) wire of the Nextion pin 10 and the yellow (RX) wire to pin 11.
Step 4: Test
Open the serial monitor and set the baud rate to 57600 bits per second. See the info that comes in from the Nextion as you press different buttons