Code help please

1st- I’m no coder, so i read and follow instructions.

2nd, Sorry if i posted this in the wrong forum.

3rd- I’m trying to set the brightness of an rgb led using Fastled library i have search everywhere either i’m not understanding or can’t find good info.

here is the section i need help with:

 else if (action == "setBrightness") {
          String brightness = json ["value"]; // here i get the value set (e.g (64))
          brightness = brightness.toInt();     // here i set the string to int
          leds.fadeLightBy(brightness);         // here brightness is the value for the led's to be set to (e.g brightness =(64))
          Serial.println(brightness);
          
        }

any help will be appreciated thanks in advance.

(deleted)

You actually don't need the FastLED library to adjust the brightness of an RGB LED. The Arduino UNO (assumed) has six pins capable of what is called pulse-width modulation. This is basically like a way to vary voltage output from the Arduino's digital pins. If you look online, you can see the syntax for PWM-ing an RGB LED and more.

Bottom line is, if you're trying to PWM an LED with this library, you are wasting your time. If you have a specific reason as to why you are using FastLED, then not your fault, but on the basis of RGB LED usage, you don't need FastLED.

He could be using a smart RGB LED

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

  • What controller are you using?
  • What RGB LED are you using?
  • Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
  • Can you please tell us your electronics, programming, Arduino, hardware experience?
  • Please post the code you have.
  • What is it doing?

Thanks.. Tom.. :slight_smile: