Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
Change Ticker interval/timeout/delay at runtime?
Hi Guys,
Could someone please let me know if its possible to change the interval which is attached to the ticker on runtime based on some conditions?
Thanks and Regards, Neil
1 Answer
9 years, 3 months ago.
You sure can. Here's a code snippet I just tested on a K64F:
#include "mbed.h" Ticker tick; DigitalOut myled(LED1, 0); void flip(void) { // flip function myled = !myled; } int main() { while(1) { tick.attach(&flip, 0.25); wait(5); tick.detach(); tick.attach(&flip, 1); wait(5); tick.detach(); } }