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.
example2.h
00001 00002 /* Example using a Ricker to make a callback to a C++ object/method */ 00003 00004 #include "mbed.h" 00005 #include "Ricker.h" 00006 00007 DigitalOut led1(LED1); 00008 DigitalOut led2(LED2); 00009 DigitalOut led3(LED3); 00010 DigitalOut led4(LED4); 00011 00012 Ticker t1; 00013 Ticker t2; 00014 Ricker r3; 00015 Ricker r4; 00016 00017 class Flipper { 00018 protected: 00019 DigitalOut *_d; 00020 public: 00021 Flipper(DigitalOut *d) { _d = d; } 00022 void flip(void) { *(_d) = !*(_d); } 00023 }; 00024 00025 int main() { 00026 00027 led1 = 1; 00028 led3 = 1; 00029 00030 Flipper f1(&led1); 00031 Flipper f2(&led2); 00032 Flipper f3(&led3); 00033 Flipper f4(&led4); 00034 00035 t1.attach(&f1, &Flipper::flip, 0.25); 00036 t2.attach(&f2, &Flipper::flip, 0.25); 00037 r3.attach(&f3, &Flipper::flip, 0.25); 00038 r4.attach(&f4, &Flipper::flip, 0.25); 00039 00040 while(1) { } 00041 }
Generated on Wed Jul 13 2022 20:31:44 by
1.7.2