<?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>while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13808/while-loop-for-led-blinking-not-working</link><description>Hello, 
 I have created the simple software usign NRF51DK to make the led blink for 5 times by using while loop
just to make the other part of my software
my aim of this program is to create pwm pulses for five times so i am started doing the simple</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 May 2016 15:45:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13808/while-loop-for-led-blinking-not-working" /><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52761?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 15:45:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37659415-1366-47e9-acd2-52df01a586ff</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;the main reason for this question i have explained clearly above but once again to create (PWM pulses) produce different sounds on the  piezo buzzer with changing the delay&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52760?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 15:26:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:682578db-4fbd-4023-aeab-c3c7849fb462</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Is that really a serious question? 5 toggles followed by one on is  is On-Off-On-Off-On-On which is 3 flashes in total.&lt;/p&gt;
&lt;p&gt;This really has nothing whatsoever to do with Nordic either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52762?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 14:02:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ab7c75b-4cd7-4055-8bfc-53284aaa740d</guid><dc:creator>Jorge</dc:creator><description>&lt;p&gt;using toggle if you want it to turn on 5 times you need to set your while to &lt;code&gt;i&amp;lt;10&lt;/code&gt;. you only get 3 times because he starts off -&amp;gt; on -&amp;gt; off -&amp;gt;on -&amp;gt;off -&amp;gt;on! five transitions = to 3 times led on.&lt;/p&gt;
&lt;p&gt;PS - when you edit your question/answer, if you edit some minor things check the box &amp;quot;minor edit&amp;quot; below the save. this way I only get one email, and not a bunch ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52759?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:53:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c5bd378-60ee-43fb-afb1-9dbe08b1049a</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;hello i just tested the same program for toggling the led for five times but the LED turnON and OFF only for three times but as per my condition it should  toggle for five times right but what is wrong in my toggling logic&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    static int i=0;             
    while(i&amp;lt;5)
    { 
        nrf_gpio_pin_toggle(LED_1); 
        nrf_delay_ms(500);    
        i++;
    }
    nrf_gpio_pin_set(LED_1);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52758?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:49:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22dbca0a-e50e-4b6e-ad78-d824b3236bdd</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;Thank you so much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52757?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:45:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:223010fc-b4de-4522-a2b1-36122b59b58a</guid><dc:creator>Jorge</dc:creator><description>&lt;p&gt;Now it&amp;#39;s working because now you clear(turn off the led) the pin, wait 50ms, set (turn on the led) the pin, wait 50 ms and clear the pin again. This way the led is off 50ms, and on 50ms, five times.&lt;/p&gt;
&lt;p&gt;Before you were clearing the pin, wait 50ms, set the pin and clear the pin again. This way your led is off 50ms, and on just a cycle of the program that is to fast for you to see.&lt;/p&gt;
&lt;p&gt;Hope this helped.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52756?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b57c2541-a38d-442b-9aa5-432a4ca3d29b</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;Thank you very much its working but could you please tell me the brief answer for the my question  what is wrong on my program why it is working only if i add two delays? can you please give me some explanantion&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: while loop for led blinking not working</title><link>https://devzone.nordicsemi.com/thread/52755?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:20:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c10850fc-fce0-4d50-bc5a-24fe62ec6073</guid><dc:creator>Jorge</dc:creator><description>&lt;p&gt;So your LED stays turned on or off? If it is off try to put another delay after the &lt;code&gt;nrf_gpio_pin_set(LED_1)&lt;/code&gt;. Maybe it is doing what you want, but is too fast for you to see.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>