Turning LED's off

This is the basic and I mean basic sketch that I am using. I've built a light with an LDR in it so I can put it on my patio and trying to make it a automatic on in dark, off in light..... nothing new here.

Here's the part of the sketch I'm using and for some reason I cannot get this to turn off.... not really sure why. I think I'm missing something simple here but it eludes me :slight_smile:

void loop(){
  
  ldr = analogRead(LDR); 
  ldrValue = map(ldr, 0, 40, 15, 0);
  
   
  // For testing so you can set your above ldrValue map function
   Serial.print("\t ldr :");
   Serial.println(ldr);
   //Serial.print("ldrValue :");
   //Serial.print(ldrValue ); 

if (ldr > 20){
  Fire2012(); // run simulation frame
  FastLED.show(); // display this frame
  FastLED.delay(100 / FRAMES_PER_SECOND);
}  else {
  FastLED.clear();
  }
  delay(10);  //repeat every 0.1 second
}

That should be very straight forward and turn it off when LDR value drops..... however it's not. It stays on... suggestion? Thanks all!

No ".show" in the clear section.

Uhhhhhh I KNEW I should have done that and didn't.... still learning. LOL Thank you, fixed!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.