Tedd OKANO / Mbed 2 deprecated ________flipper
Revision:
0:d5cc979e064a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 26 06:28:42 2012 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+// A class for flip()-ing a DigitalOut 
+class Flipper {
+public:
+    Flipper(PinName pin) : _pin(pin) {
+        _pin = 0;
+    }
+    void flip() {
+        _pin = !_pin;
+    }
+private:
+    DigitalOut _pin;
+};
+
+DigitalOut led1(LED1);
+Flipper f(LED2);
+Flipper f3(LED3);
+Ticker t0;
+Ticker t1;
+Ticker t2;
+Ticker t3;
+
+int main() {
+    t0.attach(&f3, &Flipper::flip, 0.7); // the address of the object, member function, and interval
+    t1.attach(&f, &Flipper::flip, 0.5); // the address of the object, member function, and interval
+
+    // 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