Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:d5cc979e064a, committed 2012-03-26
- Comitter:
- okano
- Date:
- Mon Mar 26 06:28:42 2012 +0000
- Commit message:
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 |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Mar 26 06:28:42 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5284544d04b6