/*############################################################# Program Name : ex2_timer_interrupt Author : Grant Phillips Date Modified : 16/01/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : Example program to demonstrate the use of the Ticker class to generate a timer interrupt repeatedly. Requirements : * STM32F4-Discovery Board Circuit : * a pushbutton connected to PA0 (user button) * LEDs connected to PD13 and PD15 ##############################################################*/ #include "mbed.h" DigitalIn button(PA_0); DigitalOut orangeled(PD_13); DigitalOut blueled(PD_15); Ticker t; void toggleroutine() { blueled = !blueled; } int main() { t.attach(&toggleroutine, 0.2); //call toggleroutine every 0.2 seconds (200ms) while(1) { while(button == 1) { //do nothing //when button is pressed, the code will get stuck in this loop //and the orange led will stop flashing, but the toggleroutine //will still run due to the timer interrupt } orangeled = !orangeled; wait(0.5); } }