need a help

Hi everyone

i want to make this condition in arduino but i dont know how for example :
if(i'am in nextion page numbe 1)
{
do this task;
}
help me please

How will you know which Nextion page you are on ?
Do you have a variable that holds the page number ? If not then introduce one
Your program presumably controls which page is displayed

UKHeliBob
yes i have for exaple page 1 it have variable page1
can i help me how can i write this condition

You need a single variable that holds the page number
Some pseudo code for you to base the real code on

page equals 1
start of loop
  if page = 1
     //code for page 1
     //including code to change page
    page = 2  //move to page 2

  else if page equals 2
     //code for page 2
     //including code to change page
    page = 1  //move to page 1
  end if
end of loop

The real code for the test of page number will look like this

if (page == 1)
{
  //code here for page 1
}
else if (page == 2)
{
  //code here for page 2
}

I propose to also look at the switch statement:

switch/case is what I would use but I was trying to keep the example simple

Let's see how the OP responds

I didnt understand how i can do it
Be more clear please

What have you tried so far and what was the result?
Please post your code here.

nabil1:
I didnt understand how i can do it
Be more clear please

I am not sure how I be any clearer

Please post your code following the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

michael_uray:
I propose to also look at the switch statement:
switch...case in C Programming

(conditions == 1 && branches > 2 && priorityCases == 0) ? useSwitch() : useIfElse();

Hi nabil,

you seem to be a newbee about programming arduinos.
Do you have some basic code that show something on the nextion-display?
If yes please post this code this way:

You should post code by using code-tags
There is an automatic function for doing this inthe Arduino-IDE
just three steps
19 press Ctrl-T for autoformatting your code
2) do a rightclick with the mouse and choose "copy to forum"
3) paste clipboard into write-window of a posting

if english is not your native language
I recommend using google-translate
write your questions in your native language and let do
google translate the translation to english

best regards Stefan

StefanL38
okey thank you

i simplified my arduino code

i want to verify if my current nextion page is the same to page 0
if this condtion is verified so arduino turn on Led
so how can i make this condtion work

here my nextion and arduino file i wish you can help me

projet - Copie.zip (1000 KB)

I have not quickly found a solution for the library you use now, but the EasyNextionLibrary provides the current page in the variable 'currentPageID'.

It is used in this example there, perhaps you want to give this library a try:

It is probably possible with your library (ITEADLIB_Arduino_Nextion) as well, maybe others can show a solution how to do it with it.

michael_uray
thanks friend
is the only possibility to get the id page is when i press the page nextion
if there is another possibility tell me please
i want to get the id without pressing the page by using "get dp" in nextion and send it to arduino

I am unfortunatly not familiar with this display and its library, but I have seen that there are callback functions which could help you.

There are also some other threads in this forum where the "get current page" topic is discussed, I suggest to also look through these entries.

I propose to change the topic of this thread to something more meaninfull, this also increases the chance that someone will notice and answer it.

Hi Nabil,

I donwloaded your code. Hm there is almost nothing inside.
the nextion-screen seems to do everything in the backround.
I have never used a nexion-display. SO I really don't know how to do it.

You should re-edit your titel to something like "Nexion-display retrieving pagenumber"

to invoke the interest of people that know how the nexion-display work.
I'm very sure that there are plenty of examples on the nexion website.
Using their displays is so different from any standard 16x2 or 20x4 LC-Display
there must be documentation and tutorials online.

You want to use it. So it is up to you to provide demo-codes and a link where the documentation can be downloaded.

I really recommend writing your questions in detail in your native language and then let do google the translation.
Your postings are really short and hard to understand. You will erode the patience of the users here for you if you go on posting so short that a lot of things have to be asked back.

by the way what is your native language. The zip-file copie sounds like french

#include <SoftwareSerial.h>
#include "Nextion.h"
NexPage page0=NexPage(0,1,"page 0");
NexPage page1=NexPage(1,1,"page 1");
NexPage page2=NexPage(2,1,"page 2");

unsigned int  pinLed=2;
void setup(void) {
   // put your setup code here, to run once:

    pinMode(pinLed,OUTPUT);
    digitalWrite(pinLed,LOW);
  Serial.begin(115200);
  Serial1.begin(115200);
  nexInit();  
}
void loop(void) {
 // i want to compare the current page nextion if its the same to page 0
 // so i turn Led on for 500ms
  if(  ) 
  {
    digitalWrite(pinLed,HIGH);//turn led on 
    delay(500);
     digitalWrite(pinLed,LOW);
  }      
}

best regards Stefan

thanks friend i apreciate your answer

StefanL38
yes i study in french i know my english it not good but im trying to improve it

"I donwloaded your code. Hm there is almost nothing inside.
the nextion-screen seems to do everything in the backround.
I have never used a nexion-display. SO I really don't know how to do it."

yes i know there is nothing inside because i want just to get the current page ID and in arduino i campare it if the current page have the same ID (to page 0) so i do the instruction inside if statement

thanks again

waiting for title of your thread beeing changed to

"learning to use nextion Display"

to attract nextion-users to your thread

waiting for a code-example of you trying to achieve getting the nextion-page-ID
.....-----.....-----.....-----.....-----.....-----.....-----.....-----

nabil1:
yes i know there is nothing inside because i want just to get the current page ID and in arduino i campare it if the current page have the same ID (to page 0) so i do the instruction inside if statement

Does this actually mean, "I only want to show you the code that does one particular thing, the rest will not help you understand it so I will not post it"?