mbed school / Mbed 2 deprecated mbed_ticker

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 Ticker flipper;
00004 DigitalOut led1(LED1);
00005 bool c=false;
00006 void flip() {     
00007     while (!c) {
00008         led1 = !led1;
00009     }
00010     led1=1;
00011 }
00012  
00013 int main() {
00014 
00015     flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
00016     // spin in a main loop. flipper will interrupt it to call flip
00017     while(1) {
00018         unsigned long n=100000000;
00019         float x=0;
00020         while(x*x <n)
00021             x = x + 0.01 ;   
00022         c=true;
00023     }
00024 }