10 years, 4 months ago.

Can't get Timeout to work

Take a look on this code:

  1. include "mbed.h"

Timeout flipper; DigitalOut led1(LED1);

void flip() { led1 = !led1; }

int main() { flipper.attach(&flip, 2.0);

while(1) { wait(4.0); printf("asd\r\n"); } }

The led is not blinking, I've been trying with both the online compiler and my offline toolchain, on the offine toolchain I set a breakpoint on the line that should flip the led and the execution doesn't get there. I tested the code on a F401RE and on a L152RE, same result.

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

1 Answer

10 years, 4 months ago.

You may want to look up the difference between timeout and ticker. It may also be worthwhile to initialise your led1 object to either 1 or 0 before you call flipper.attach(). I hope this helps.

Accepted Answer