A ticker blinky implementation.

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 DigitalOut led2(LED2);
00006  
00007 void flip() {
00008     led2 = !led2;
00009 }
00010  
00011 int main() {
00012     led2 = 1;
00013     flipper.attach(&flip, 2.0); // call flip function every 2 seconds 
00014 
00015 
00016     // spin in a main loop. flipper will interrupt it to call flip
00017     while(1) {
00018         led1 = !led1;
00019         wait(0.2);
00020     }
00021 }