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

How to vary the LEDs blink rate

Hi all,

I am trying to figure out how to change the LEDs blink rate on the go.

I have set up the timers_init() and let say every 500ms sensor data is read on dev kit and transmitted to a smart phone. According to the sensor data I want to change the blink rate of the LED/LEDs on dev kit. What would be the best method to achieve this?

Thanks for advice ;)

Milan

  • Hi

    If you look at for example ble_app_bps in nRF51 SDK 7.1.0, there are two function calls in the main function for the application timers, timers_init() and application_timers_start(). If you look at application_timers_start(), the battery service timer is started with:

    app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL);
    

    Changing the value of the BATTERY_LEVEL_MEAS_INTERVAL constant will change interrupt frequency of this application timer.

    Update 14.1.2014 If you want to update the application timer update freqeuency dynamically, I think the best way to do that is to stop the timer and start it again with a new value. Some discussion about that is on this thread

  • Thanks for reply. I thought that the BATTERY_LEVEL_MEAS_INTERVAL applies only once during initialisation. (Currently 2000ms) Right? Or do you suggest that I can call the app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL); function again in order to modify the timers rate? That would be a solution.

    Yeap the update shows what I was looking for. Many thanks.

Related