Hello World for Ticker

Dependencies:   mbed

Dependents:   blog_PID

mbed 2 and mbed OS 5

This is an mbed 2 example. For an mbed-os example, please see:

Import programTicker_HelloWorld

Hello World for Ticker

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Thu Feb 14 14:30:22 2013 +0000
Commit message:
Ticket Hello World

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5014bf742e9b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 14 14:30:22 2013 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+ 
+Ticker flipper;
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+ 
+void flip() {
+    led2 = !led2;
+}
+ 
+int main() {
+    led2 = 1;
+    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) {
+        led1 = !led1;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 5014bf742e9b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 14 14:30:22 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file