You are reading a single comment by @Chaapu and its replies. Click here to read the full conversation.
  • You are right, I was unnecessarily complicating things. Thanks a lot for your suggestion @DrAzzy

    This is what I have got now

    let ledBrightness = 0;
    let ledPin = D15;
    let fadeIn = false;
    
    function fadeLED() {
     if((ledBrightness <= 0) || (ledBrightness >= 1)){
       fadeIn = !fadeIn;
     }
      
      setLedBrightness(fadeIn);
    
    }
    
    function setLedBrightness(fadeIn){
        if(fadeIn){
        ledBrightness += 0.01;
      }
      else {
        ledBrightness -=0.01;
      }
      
      analogWrite(ledPin, ledBrightness);
    }
    
    setInterval(fadeLED , 10);
    
    
About

Avatar for Chaapu @Chaapu started