This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

while loop for led blinking not working

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 software by using LED

Issue: when i flashed the program the led blink for the first and only one time and then cleared completely but my aim is to blink (on and off for five times)

could anyone please tell me what mistakes in my logic? or possible things i have to take care inorder to make the led blink for 5 times

int i=0;

while(i<5)

{

								 // Start LED here
               nrf_gpio_pin_clear(LED_1);
								  nrf_delay_ms(50);
								  nrf_gpio_pin_set(LED_1);
								i++;

							}
Parents
  • using toggle if you want it to turn on 5 times you need to set your while to i<10. you only get 3 times because he starts off -> on -> off ->on ->off ->on! five transitions = to 3 times led on.

    PS - when you edit your question/answer, if you edit some minor things check the box "minor edit" below the save. this way I only get one email, and not a bunch ;)

Reply
  • using toggle if you want it to turn on 5 times you need to set your while to i<10. you only get 3 times because he starts off -> on -> off ->on ->off ->on! five transitions = to 3 times led on.

    PS - when you edit your question/answer, if you edit some minor things check the box "minor edit" below the save. this way I only get one email, and not a bunch ;)

Children
No Data
Related