This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RGB LED with NRF5340

Hi,

I need your help to know "How to control RGB LED using PWM in nrf5340?". I have already tried the "RGB_led" sample in NRFconnect SDK v1.5.0 

But can't able to control my led. Kindly Support me to understand the Project and also to get output.

Thanks & Regards 

Navin Chakravarthy K

Parents Reply Children
  • Hi Priyanka,

     I want to use via PWM individual mode of nrf5340 or SDK already has RGB LED samples  I need to know how to use that sample for nrf5340

    Thanks & regards

    Navin

  • Hi Navin,

    Since the nrf5340 has only 4 green LEDS, and does not have dedicated red or blue LEDs, while running the ''rgb_led'' exampleyou will have to consider any two LEDs to be red and blue respectively (for eg: led0 -> green, led1-> blue, led2 -> red) 

    Making any changes in the main.c file may cause errors so it would be better if this change is reflected in the .dts file. For which, you don't have to modify that, but you can create a .overlay file inside the ''rgb_led'' folder. Here, you can mention the changes that you want to see in the .dts file (the LEDs you wish to set). 

    This will help you build and flash the program onto the DK. 

    Also, I would recommend you to use the latest version of nrf Connect.

    Hope this helps Slight smile

    Kind Regards,

    Priyanka

  • Hi Priyanka,

    Basically, RGB led means multicolor controllable led. For your reference "www.circuitbread.com/.../how-rgb-leds-work-and-how-to-control-color"

    And that can be controlled via PWM. Kindly, Check that link and suggest a way to control multicolor led with nrf5340

    Thanks & Regards

    Navin Chakravarthy K

  • Hi Navin,

    I guess there was a bit of a confusion in what I mentioned yesterday. I get that an RGB Led is a multicolour LED but there is no such LED on nrf5340 DK. It has just 4 green LEDs.

    But if you need to run the 'rgb_led' example with an RGB Led, then you will have to use an external analog RGB Led and also, create a  .overlay file with the necessary pwm leds initialised. You can do it like I mentioned yesterday.

    Priyanka said:
    Making any changes in the main.c file may cause errors so it would be better if this change is reflected in the .dts file. For which, you don't have to modify that, but you can create a .overlay file inside the ''rgb_led'' folder. Here, you can mention the changes that you want to see in the .dts file (the LEDs you wish to set). 

    I will attach my .overlay file for your reference. Also, make sure your RGB led pins are connected to the proper pins and you can calculate the resistance required by using your voltage supply and current limit from the datasheet of the RGB Led.

    As for controlling the LED, you could try making changes in the main.c of the 'rgb_led' example. At present, it runs as per a for loop with a specific count that is defined. You could try changing this. In case you need to control them via buttons, you may have to again define them in the .overlay file.

    5305.nrf5340dk_nrf5340_cpuapp.overlay

    Hope this helps.

    Kind Regards,

    Priyanka

  • Hi Priyanka,

    Sorry for the delay, Now I am facing some issues because of nrf connect to update. Afterward, I will contact you

    Regards

    Navin

Related