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
  • Now it'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.

    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.

    Hope this helped.

Reply
  • Now it'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.

    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.

    Hope this helped.

Children
Related