problem with ws2812 leds, problem with code pls help

this is a part of my code, program works perfect except for 1 thing: when i start the program and keep my finger in front of the sensor the leds fade up and down as they should, then when i dont put my finger anymore in front of the sensor it should put the leds on solid red... this doesnt happen.

BUT when i press the reset button to reset the arduino and the code starts again, when i dont put finger in front of the sensor at all it jumps to solid red as it should.. i dont know how this can happen.

here is the code:

if (ir1status == 1 && start == 0) {

strip.clear(); strip.fill(rood, 0, 16);; Serial.println("testtest"); start = HIGH;

} if (start == HIGH ) {

Serial.println("normale cyclus"); team1(); // team2(); } else {

int x = 1; for (int i = 0; i > -1; i = i + x) { strip.fill(rood, 0, 16); strip.setBrightness(i);; if (i == 100) { x = -1; // switch direction at peak } delay(10); } }

here is the code:

No. We need all the code, and a schematic, because your explanation is insufficient for anyone to understand what is going on.

Also please read this:-
How to use this forum
Because your post is breaking the rules about posting code.