Start a new topic

"If" conditions + Comparison operators (== != < >) in Nextion Editor

Is it possible to write some simple conditions in User Code for Touch Press Events ?

For instance I would like to prevent the user from adjusting the brightness down to 0, otherwise the display becomes completely dark.

For the moment I have this User Code for Touch Press Event of a button:


I would like to change it to something like this:

if dim>10: dim=dim-10


if dim==0: dim=10

or something similar.

7 people like this idea

Maybe a syntax like in Arduino would be better, like this:

if (dim>10) dim=dim-10


2 people like this

Where can I find this whole code?
Also code for Arduino UNO?

Best regards



I forgot to mention this page where you will find a lot of Arduino code from Chris Sipes :


ITEAD is updating the Arduino library, and new examples are available in the 'examples' directory on

Use of simple conditional statements like "if & else" will make the programming of Nextion module more creative!


The "IF" function has been implemented in Nextion Editor v0.28. Thank you @ITEAD.

See this thread:

We are listening to the voice of customers. :)


How can I compare txt value using if?

When i write like this code it doesn't work. 

page big
page small


but when i write this code it works correctly.

page big


I know how to use comparison operators in if conditions. But it doesn't work when I use txt object in if condition.

I doubt it ever will because the text could be anything. And it would require a string function like strcmp. With that said try adding " around your values.

I am now reviewing all of the Feature Requests, this will take some time, patience please.

The if function has been improved dramatically.