<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>I&amp;#39;m trying to control the brightness of the LEDs of my dev kit with the buttons</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87803/i-m-trying-to-control-the-brightness-of-the-leds-of-my-dev-kit-with-the-buttons</link><description>Hi, 
 I’m really new to zephyr and nrf SDK (I currently use nrf connect on vscode) and I have a project which consist in remotely controling the brightness of the 4 LEDs built in my nrf52840 dk using bluetooth mesh (I have 3 kits). I apologize in advance</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 May 2022 10:28:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87803/i-m-trying-to-control-the-brightness-of-the-leds-of-my-dev-kit-with-the-buttons" /><item><title>RE: I'm trying to control the brightness of the LEDs of my dev kit with the buttons</title><link>https://devzone.nordicsemi.com/thread/368793?ContentTypeID=1</link><pubDate>Fri, 20 May 2022 10:28:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bae36be-1bc9-44c1-84c3-42e3d453f938</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;No problem at all!&lt;/p&gt;
[quote user="Bastien"]It might be useful to include some informations about the device tree in the sample since only one LEDs is configured as pwm.&amp;nbsp;[/quote]
&lt;p&gt;That is a good point, I will pass that on to the relevant team.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I'm trying to control the brightness of the LEDs of my dev kit with the buttons</title><link>https://devzone.nordicsemi.com/thread/368776?ContentTypeID=1</link><pubDate>Fri, 20 May 2022 09:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07c82860-2485-425f-972a-60bec501b10f</guid><dc:creator>Bastien</dc:creator><description>&lt;p&gt;Hi, thank you very much for your help, your explanations were very clear. Now that I understand how the device tree works, everything is much easier ! It might be useful to include some informations about the device tree in the sample since only one LEDs is configured as pwm.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for your time,&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Bastien&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I'm trying to control the brightness of the LEDs of my dev kit with the buttons</title><link>https://devzone.nordicsemi.com/thread/368771?ContentTypeID=1</link><pubDate>Fri, 20 May 2022 09:27:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bba099a-f72b-4c63-a87a-7453ea6b9aba</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Bastien, sorry about the wait.&lt;/p&gt;
&lt;p&gt;And no worries about the questions, everything&amp;nbsp;is allowed here.&lt;/p&gt;
[quote user=""]the “led_set_brightness” function doesn’t seem to use gpios like the on/off function does. And also, I don’t understand what this part means (the #defines are different from the way I used them in the first program :[/quote]
&lt;p&gt;&lt;span&gt;The led_set_brightness function uses all the available pwm-leds as a node, not a specific one. When it comes to the rest of the defines:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;LOG_MODULE_REGISTER is only about logging, and not too relevant for this. &lt;a href="https://academy.nordicsemi.com/topic/logger-module/"&gt;For more info on logging see here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#if DT_NODE_HAS_STATUS(DT_INST(0, pwm_leds), okay)
#define LED_PWM_NODE_ID		DT_INST(0, pwm_leds)
#define LED_PWM_DEV_NAME	DEVICE_DT_NAME(LED_PWM_NODE_ID)
#else
#error &amp;quot;No LED PWM device found&amp;quot;
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The above defines adds all the pwm-led that have an &amp;quot;okay&amp;quot; status to the pwm-leds node.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define LED_PWM_LABEL(led_node_id) DT_PROP_OR(led_node_id, label, NULL),

const char *led_label[] = {
	DT_FOREACH_CHILD(LED_PWM_NODE_ID, LED_PWM_LABEL)
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This adds all the pwm-led nodes to the led_label list.&lt;/p&gt;
&lt;p&gt;Note that you got the&amp;nbsp;led_pwm sample (the second code snippet you provided) to work with only one LED, but the code is set to use all pwm-leds with an &amp;quot;okay&amp;quot; status.&amp;nbsp;You can confirm that led1 is the only one set by taking a look at the .dts file of the board. If you add the code below to an overlay file (ie. nrf52840dk_nrf52840.overlay) you will see that all 4 of the LEDs are being used.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/ {
    pwmleds {
        compatible = &amp;quot;pwm-leds&amp;quot;;
        pwm_led0: pwm_led_0 {
            pwms = &amp;lt; &amp;amp;pwm0 13 &amp;gt;;
        };
        pwm_led1: pwm_led_1 {
            pwms = &amp;lt; &amp;amp;pwm1 14 &amp;gt;;
        };	
        pwm_led2: pwm_led_2 {
            pwms = &amp;lt; &amp;amp;pwm2 15 &amp;gt;;
        };	
        pwm_led3: pwm_led_3 {
            pwms = &amp;lt; &amp;amp;pwm3 16 &amp;gt;;
            
        };	
    };
};
&amp;amp;pwm0 {
    ch0-pin = &amp;lt;13&amp;gt;;
    ch0-inverted;
    status= &amp;quot;okay&amp;quot;;
};
&amp;amp;pwm1 {
    ch0-pin = &amp;lt;14&amp;gt;;
    ch0-inverted;
    status= &amp;quot;okay&amp;quot;;
};
&amp;amp;pwm2 {
    ch0-pin = &amp;lt;15&amp;gt;;
    ch0-inverted;
    status= &amp;quot;okay&amp;quot;;
};
&amp;amp;pwm3 {
    ch0-pin = &amp;lt;16&amp;gt;;
    ch0-inverted;
    status= &amp;quot;okay&amp;quot;;
};
&lt;/pre&gt;&lt;/p&gt;
[quote user=""]I have now idea how considering that the “led_set_brightness” function[/quote]
&lt;p&gt;To change the brightness I would stick with the&amp;nbsp;led_set_brightness() function. &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/led.html?highlight=led_set_brightness#c.led_set_brightness"&gt;For more info on how to use it see here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let me know if there is anything that I haven&amp;#39;t cleared up yet.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I'm trying to control the brightness of the LEDs of my dev kit with the buttons</title><link>https://devzone.nordicsemi.com/thread/367858?ContentTypeID=1</link><pubDate>Fri, 13 May 2022 13:24:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee6d74fd-960d-444d-a819-9d63b5ef7f82</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Bastien,&lt;/p&gt;
&lt;p&gt;I will get back to you on this next week.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>