Start a new topic

Counter to X with 1 in 1 button

Hello, I have the enhanced nextion of 7 ".

I want to use a + and - buttons to set a specific time of day to activate one of the output pins for a device.
I do not want to configure rtc time, I already have it configured


I have been able to add 1 each time I press the + button, but I can not stop it when I hit 23.

If I put

If (n0.val <24) {
N0.val = n0.val + 1;
}

Does not work, gives syntax error


You have a capitalisation errors (If and N0.val), with spaces and semi-colon which are not correct.

Here is the correct format  

if(n0.val<24)
{
n0.val=n0.val+1
}

 Or more simply 

if(n0.val<24)
{
n0.val++
}

  



The { brace needs to start on a line by itself indicating the beginning of a code block.


also n0.val+=1 is also acceptable.

if wanting to stop at 23 then your n0 evaluation can not be as written


if(n0.val<24)

{

  n0.val=n0.val+1

}


When n0 is 23, the condition of n0.val<24 is true

  therefore the block n0.val=n0.val+1 is also executed.


1 person likes this
Login or Signup to post a comment