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, 8 months ago.
Timer
Is it possible to use the timer to count down from 10 sec and once it hit 0, it will lets say turn off a led or enable a pin?
Question relating to:
1 Answer
9 years, 8 months ago.
Yes. Well the timer itself is an upcounter, but you can do the same by letting it count up to 10 secs and do something once it reaches that. For example:
Timer timer; DigitalOut led(LED1); timer.start(); while(timer.read() < 10); //Wait until timer is larger than 10 led = 1;
There are many other options to implement this behavior. Also have a look at using https://mbed.org/handbook/Ticker or https://mbed.org/handbook/Timeout