Start a new topic

Code for Dual state Button Nextion and Arduino UNO



Hope you can help me out, I want to control 2 relays ON/OFF, from my Nextion 4,3" screen to my Arduino UNO.


On youtube i can find plenty of videos showing how this works, but no code for the Arduino UNO. Can you provide me an example for a code. My plan is that the dual state button will change one pic. To another pic when I press it, this part I have figured out whit crop image in the Nextion editor. Also I have changed the config.h file so I can use RX and TX from Nextion to my Arduino. But can still not figure out how to make the code.


Thanks in advance Michael 

simply speaking ...

when you press the button, the Nextion does not only change the pic ...

in his press or release action you must add a sending command, which send out a defined notification, based on the button status ...

like  (pseudocode)

    if button status=0 print "A"

    if button status=1 print "B"

at Arduino side, you must wait for serial incoming, and catch either the "A" or the "B" and set your relay-pin according to the received ...

Thank you Gerry for quick reply. I do add sending command in Nextion editor. and use the nextion library. If I use your example will it only be the text if self changing on nextion display or can I have at picture that change from ON to OFF and visa versa

Login or Signup to post a comment