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.
8 years, 2 months ago.
I create two timer, and attach it to tow function, but only one can runing
- include "mbed.h"
Timeout timeout; Timeout timeout2; DigitalOut led(LED1); DigitalOut led2(LED2);
int on = 1; int cnt = 0; int cnt2 = 0;
void attimeout() { timeout.attach(&attimeout, 0.000004); if(++ cnt == 250000) { cnt = 0; led = !led; } on = 0; }
void attimeout2() { timeout2.attach(&attimeout2, 0.00004); if(++ cnt2 == 25000) { cnt2 = 0; led2 = !led2; } on = 0; }
int main() { timeout.attach(&attimeout, 0.000004); only this one can runing timeout2.attach(&attimeout2,0.00004); while(1); wait(0.2);
}