ITEADLIB_Nextion Slider value help

@Scruff, sorry but I’m running into another problem. I’m kind of a noob when it comes to coding on as big of a scale I am in this project. Im using 2 sliders to set preferences for when I hit the start button. I can’t get the values of the sliders to be used in the running function. I want the a different combination of LEDs to light up depending on what the sliders values are. However the values of the sliders don’t seem to be having an impact on the lights that light up. The sliders are on a different page so I set their vscope to global so the values don’t reset once the page is changed back to the main screen where the start button is.

Here is the code.

if(Start_State)
{
    
    LengthSelect.getValue(&MixingTime);  //Slider 1  (value goes from 0 to 100)
    
    WaterSelect.getValue(&WaterAmount);  //Slider 2  (value goes from 0 to 100)
    
    
    if((0 <= MixingTime <= 33) && (0 <= WaterAmount <= 33))
    {
        digitalWrite(BLUE, HIGH);
        digitalWrite(YELLOW, HIGH);
        delay(1000);
        SB->setValue(0);
        digitalWrite(BLUE, LOW);
        digitalWrite(YELLOW, LOW);
    }
    
    else if((34 <= MixingTime <= 66) && (0 <= WaterAmount <= 33))
    {
        digitalWrite(GREEN, HIGH);
        delay(1000);
        SB->setValue(0);
        digitalWrite(GREEN, LOW);
    }
    
    else if((67 <= MixingTime <= 100) && (0 <= WaterAmount <= 33))
    {
        digitalWrite(BLUE, HIGH);
        digitalWrite(RED, HIGH);
        digitalWrite(GREEN, HIGH);
        digitalWrite(YELLOW, HIGH);
        delay(1000);
        SB->setValue(0);
        digitalWrite(BLUE, LOW);
        digitalWrite(RED, LOW);
        digitalWrite(GREEN, LOW);
        digitalWrite(YELLOW, LOW);
    }

I feel like I could just be trying to use the values in the wrong mannor or be typing the code improperly. Any feedback, advise, or help is greatly appreciated. More code can be provided if necessary.

I’d think in this case it’s not a Nextion problem, but in the coding

 if((0 <= MixingTime <= 33) && (0 <= WaterAmount <= 33))

This is not doing what you’d expect it to do.
You’d need to write it this way instead

 if((0 <= MixingTime && MixingTime <= 33) && (0 <= WaterAmount && WaterAmount <= 33))

the same goes for all the other places where you have similar code.


Background:
You could imagine these comparison operators (e.g. <=) like a function bool isLessOrEqual(int leftParm, int rightParm), so your code would translate to

if ( isLessOrEqual(0, isLessOrEqual(MixingTime, 33)) && isLessOrEqual(0, isLessOrEqual(WaterAmount, 33)))

And I’d say this will hardly ever return what you want since the result of the inner comparison would only ever return 0 or 1, nothing else, so your first if() will always pull.


Tip for future cases:
If you can’t make sense of the results you see, try adding some Serial.print() statements to check your variables and which branches your code is running through.
You can even do something like

  Serial.println(MixingTime);
  Serial.println(0 <= MixingTime <= 33);

to see if your conditions are actually returning the expected value (1 = true, 0 = false).