Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /*Program Example 9.4: Program which runs two time-based tasks 00002 */ 00003 #include "mbed.h" 00004 Timer timer_fast; // define Timer with name "timer_fast" 00005 Timer timer_slow; // define Timer with name "timer_slow" 00006 DigitalOut ledA(LED1); 00007 DigitalOut ledB(LED4); 00008 00009 void task_fast(void); //function prototypes 00010 void task_slow(void); 00011 00012 int main() { 00013 timer_fast.start(); //start the Timers 00014 timer_slow.start(); 00015 while (1){ 00016 if (timer_fast.read()>0.2){ //test Timer value 00017 task_fast(); //call the task if trigger time is reached 00018 timer_fast.reset(); //and reset the Timer 00019 } 00020 if (timer_slow.read()>1){ //test Timer value 00021 task_slow(); 00022 timer_slow.reset(); 00023 } 00024 } 00025 } 00026 00027 void task_fast(void){ //”Fast” Task 00028 ledA = !ledA; 00029 } 00030 void task_slow(void){ //”Slow” Task 00031 ledB = !ledB; 00032 } 00033
Generated on Tue Aug 23 2022 05:47:16 by
1.7.2