Help with boolean & neopixel needed

Hey Fellow makers,

thanks in advance for reading this.

I have this problem with my code for the arduino uno,
where i want to color a lightstripe as soon as a value comes in.
With every different value, a different color comes…

I had it working yesterday night, but my arduino crashed & i couldnt recode it…

So now I´m here in my Void loop

void loop() {
VL53L0X_RangingMeasurementData_t measure;

Serial.print("Reading a measurement… ");
lox.rangingTest(&measure, false); // pass in ‘true’ to get debug data printout!

if (measure.RangeStatus != 4) { // phase failures have incorrect data
Serial.print("Distance (mm): “); Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(” out of range ");
}

// PT 2

if ((measure.RangeMilliMeter) > 50 && (measure.RangeMilliMeter) < 100) {
ledOn = true;
}else

{ledOn = false;
}

if (ledOn == true)

{

colorWipe(strip.Color(0, 0, 255), 5);

Serial.println (" 100 " );
}

if ((measure.RangeMilliMeter) > 100 && (measure.RangeMilliMeter) < 150);

{

colorWipe(strip.Color(0, 0, 200), 5);

Serial.println (" 150 " );
}

The leds color are keeping updating really fast.
I want that the LEDs Color stays the same, until the next measures got reached…

I Can´t see my mistake here :frowning:

THANKS

Jamminben: I Can´t see my mistake here :(

That may be because your code is so poorly formatted (use IDE's auto-format feature) has a lot of whitespace (get rid of that) and isn't posted using code tags (try doing that).

if ((measure.RangeMilliMeter) > 100 && (measure.RangeMilliMeter) < 150);

In general, if statements are not supposed to end with ;. That defines a no-op, to be the body of the if statement.

I know, but I´m learning & Trying to understand. But i will def. do it in the end! thank you

BulldogLowell:
That may be because your code is so poorly formatted (use IDE’s auto-format feature) has a lot of whitespace (get rid of that) and isn’t posted using code tags (try doing that).

Thanks, didn´t see this! Now it works… Really appreciate your help!!! May the sunny high ghost of bob marley visit & share a j with you.

PaulS:

if ((measure.RangeMilliMeter) > 100 && (measure.RangeMilliMeter) < 150);

In general, if statements are not supposed to end with ;. That defines a no-op, to be the body of the if statement.