Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Led_control

Hello ,

 i use blinky example from C:\Keil_v5\ARM\Device\Nordic\nrf51822\Board\pca10001 folder. I want to flash the led with periods (period of 30 ms turn on 10 ms off)

if you can help me .

thank you

Parents
  • Hi,

    I don not know what SDK version you are using, but this is written assuming SDK v4.4.2.

    You should be able to achieve this functionality by changing the while loop to something like this:

    nrf_gpio_port_write(LED_PORT, 1 << (output_state + LED_OFFSET));
    output_state = (output_state + 1) & BLINKY_STATE_MASK;
    nrf_delay_ms(30);
    nrf_gpio_port_write(LED_PORT, 1 << (output_state + LED_OFFSET));
    output_state = (output_state + 1) & BLINKY_STATE_MASK;
    nrf_delay_ms(10);

    Best regards,
    Jørgen

Reply
  • Hi,

    I don not know what SDK version you are using, but this is written assuming SDK v4.4.2.

    You should be able to achieve this functionality by changing the while loop to something like this:

    nrf_gpio_port_write(LED_PORT, 1 << (output_state + LED_OFFSET));
    output_state = (output_state + 1) & BLINKY_STATE_MASK;
    nrf_delay_ms(30);
    nrf_gpio_port_write(LED_PORT, 1 << (output_state + LED_OFFSET));
    output_state = (output_state + 1) & BLINKY_STATE_MASK;
    nrf_delay_ms(10);

    Best regards,
    Jørgen

Children
Related