How do I use wait without halting program execution

10 Dec 2011

I am writing a program that prints a small menu to a text LCD. I am using two buttons, one to switch between the two menu items and then the other selects the menu item. When I select a menu item and activate it, I want to turn one of the LEDs on (one LED for each menu item). If I again activate the menu item, it will turn off the LED. My problem is I want the LED to blink (on for .5 seconds and .5 off). How do I blink the LED's without interrupting the LCD menu function while using wait()?

10 Dec 2011

You can use a Ticker object for blinking the LED instead of wait() calls in the main loop. This handbook page shows such an example. You should be able to call the detach() method later to stop the blinking.