mbed school
/
mbed_ticker
一階邏輯開根號計算,使用 ticker 每隔二秒執行一次 LED 閃爍,直到計算完成後恆亮
main.cpp
- Committer:
- mbedschool
- Date:
- 2015-02-14
- Revision:
- 0:41518d1f552d
File content as of revision 0:41518d1f552d:
#include "mbed.h" Ticker flipper; DigitalOut led1(LED1); bool c=false; void flip() { while (!c) { led1 = !led1; } led1=1; } int main() { flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds) // spin in a main loop. flipper will interrupt it to call flip while(1) { unsigned long n=100000000; float x=0; while(x*x <n) x = x + 0.01 ; c=true; } }