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.
main.cpp
00001 #include "mbed.h" 00002 00003 // A class for flip()-ing a DigitalOut 00004 class Flipper { 00005 public: 00006 Flipper(PinName pin) : _pin(pin) { 00007 _pin = 0; 00008 } 00009 void flip() { 00010 _pin = !_pin; 00011 } 00012 private: 00013 DigitalOut _pin; 00014 }; 00015 00016 DigitalOut led1(LED1); 00017 Flipper f(LED2); 00018 Timeout t; 00019 00020 int main() { 00021 t.attach(&f, &Flipper::flip, 2.0); // the address of the object, member function, and interval 00022 00023 // spin in a main loop. flipper will interrupt it to call flip 00024 while(1) { 00025 led1 = !led1; 00026 wait(0.2); 00027 } 00028 }
Generated on Tue Jul 12 2022 11:04:56 by
