Not sure what I'm missing. I have an If/Else that's not working right. The IF statement works fine and stops executing when it should, but the program never enters the Else statement.
void loop() {
SolidColors();
FastLED.show();
delay(1000);
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
if(sensorValue >= 50) {
int s = sensorValue/50;
for( int b = 56; b >= 56-s; b--){ //Red
leds[b] = CRGB(0,255,0);
FastLED.show();
delay(10);
Serial.println("ON");
}
}
else {
for(int b = 56; b == 36; b--) {
leds[b] = CRGB::Black;
FastLED.show();
Serial.println("Off");
}
}
Perhaps the value of sensorValue always more than 50 and else branch has no chance to run?
What about are values printed in the console? Does it exceeded 50 or not?
Yes, sensor value is pretty stable at 0 and it does print "Off" when I would expect. The second statement is an ELSE, so second FOR should run before I'm printing the OFF and Value. IE. LEDs should turn off. But if I move the two print lines inside the FOR statement it they no longer work.